Skip to content

Commit 8551ea1

Browse files
committed
OpenRouter LLM Provider
1 parent d99823e commit 8551ea1

File tree

7 files changed

+38
-9
lines changed

7 files changed

+38
-9
lines changed

core/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ type ModelProvider =
610610
| "azure"
611611
| "openai-aiohttp"
612612
| "msty"
613-
| "watsonx";
613+
| "watsonx"
614+
| "openrouter";
614615

615616
export type ModelName =
616617
| "AUTODETECT"

core/llm/llms/OpenRouter.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { LLMOptions, ModelProvider } from "../../index.js";
2+
import { osModelsEditPrompt } from "../templates/edit.js";
3+
import OpenAI from "./OpenAI.js";
4+
5+
class OpenRouter extends OpenAI {
6+
static providerName: ModelProvider = "openrouter";
7+
static defaultOptions: Partial<LLMOptions> = {
8+
apiBase: "https://openrouter.ai/api/v1/",
9+
model: "gpt-4o-mini",
10+
promptTemplates: {
11+
edit: osModelsEditPrompt,
12+
},
13+
useLegacyCompletionsEndpoint: false,
14+
};
15+
}
16+
17+
export default OpenRouter;

core/llm/llms/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Mistral from "./Mistral";
2929
import Msty from "./Msty";
3030
import Ollama from "./Ollama";
3131
import OpenAI from "./OpenAI";
32+
import OpenRouter from "./OpenRouter";
3233
import Replicate from "./Replicate";
3334
import SageMaker from "./SageMaker";
3435
import TextGenWebUI from "./TextGenWebUI";
@@ -64,6 +65,7 @@ const LLMs = [
6465
Msty,
6566
Azure,
6667
WatsonX,
68+
OpenRouter,
6769
];
6870

6971
export async function llmFromDescription(

docs/static/schemas/config.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
"deepseek",
190190
"azure",
191191
"msty",
192-
"watsonx"
192+
"watsonx",
193+
"openrouter"
193194
],
194195
"markdownEnumDescriptions": [
195196
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
@@ -214,7 +215,8 @@
214215
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
215216
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://docs.continue.dev/reference/Model%20Providers/azure)",
216217
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
217-
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
218+
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
219+
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
218220
],
219221
"type": "string"
220222
},

extensions/intellij/src/main/resources/config_schema.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
"deepseek",
190190
"azure",
191191
"msty",
192-
"watsonx"
192+
"watsonx",
193+
"openrouter"
193194
],
194195
"markdownEnumDescriptions": [
195196
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
@@ -214,7 +215,8 @@
214215
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
215216
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://docs.continue.dev/reference/Model%20Providers/azure)",
216217
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
217-
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
218+
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
219+
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
218220
],
219221
"type": "string"
220222
},

extensions/vscode/config_schema.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@
189189
"deepseek",
190190
"azure",
191191
"msty",
192-
"watsonx"
192+
"watsonx",
193+
"openrouter"
193194
],
194195
"markdownEnumDescriptions": [
195196
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
196197
"### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)",
197198
"### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)",
198199
"### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)",
199200
"### Bedrock\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock/claude/)",
201+
"### Sagemaker\nSagemaker is AWS' machine learning platform.",
200202
"### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/togetherllm)",
201203
"### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run <MODEL_NAME>`. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/ollama)",
202204
"### Huggingface TGI\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfacetgi)",
@@ -214,7 +216,8 @@
214216
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
215217
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://docs.continue.dev/reference/Model%20Providers/azure)",
216218
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
217-
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
219+
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
220+
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
218221
],
219222
"type": "string"
220223
},

extensions/vscode/continue_rc_schema.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
"deepseek",
193193
"azure",
194194
"msty",
195-
"watsonx"
195+
"watsonx",
196+
"openrouter"
196197
],
197198
"markdownEnumDescriptions": [
198199
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
@@ -217,7 +218,8 @@
217218
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
218219
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://docs.continue.dev/reference/Model%20Providers/azure)",
219220
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
220-
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
221+
"### Watsonx\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
222+
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
221223
],
222224
"type": "string"
223225
},

0 commit comments

Comments
 (0)