mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-05 08:54:55 +01:00
docs: add more providers
This commit is contained in:
@@ -45,6 +45,126 @@ You can customize the base URL for any provider by setting the `baseURL` option.
|
||||
|
||||
---
|
||||
|
||||
## Custom provider
|
||||
|
||||
To add any **OpenAI-compatible** provider that's not listed in `opencode auth login`:
|
||||
|
||||
:::tip
|
||||
You can use any OpenAI-compatible provider with opencode. Most modern AI providers offer OpenAI-compatible APIs.
|
||||
:::
|
||||
|
||||
1. Run `opencode auth login` and scroll down to **Other**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ...
|
||||
│ ● Other
|
||||
└
|
||||
```
|
||||
|
||||
2. Enter a unique ID for the provider.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Enter provider id
|
||||
│ myprovider
|
||||
└
|
||||
```
|
||||
|
||||
:::note
|
||||
Choose a memorable ID, you'll use this in your config file.
|
||||
:::
|
||||
|
||||
3. Enter your API key for the provider.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
▲ This only stores a credential for myprovider - you will need configure it in opencode.json, check the docs for examples.
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ sk-...
|
||||
└
|
||||
```
|
||||
|
||||
4. Create or update your `opencode.json` file in your project directory:
|
||||
|
||||
```json title="opencode.json" ""myprovider"" {5-15}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"myprovider": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "My AI ProviderDisplay Name",
|
||||
"options": {
|
||||
"baseURL": "https://api.myprovider.com/v1"
|
||||
},
|
||||
"models": {
|
||||
"my-model-name": {
|
||||
"name": "My Model Display Name"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here are the configuration options:
|
||||
|
||||
- **npm**: AI SDK package to use, `@ai-sdk/openai-compatible` for OpenAI-compatible providers
|
||||
- **name**: Display name in UI.
|
||||
- **models**: Available models.
|
||||
- **options.baseURL**: API endpoint URL.
|
||||
- **options.apiKey**: Optionally set the API key, if not using auth.
|
||||
- **options.headers**: Optionally set custom headers.
|
||||
|
||||
More on the advanced options in the example below.
|
||||
|
||||
5. Run the `/models` command and your custom provider and models will appear in the selection list.
|
||||
|
||||
---
|
||||
|
||||
##### Example
|
||||
|
||||
Here's an example setting the `apiKey` and `headers` options.
|
||||
|
||||
```json title="opencode.json" {9,11}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"myprovider": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "My AI ProviderDisplay Name",
|
||||
"options": {
|
||||
"baseURL": "https://api.myprovider.com/v1",
|
||||
"apiKey": "{env:ANTHROPIC_API_KEY}",
|
||||
"headers": {
|
||||
"Authorization": "Bearer custom-token"
|
||||
}
|
||||
},
|
||||
"models": {
|
||||
"my-model-name": {
|
||||
"name": "My Model Display Name"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We are setting the `apiKey` using the `env` variable syntax, [learn more](/docs/config#env-vars).
|
||||
|
||||
---
|
||||
|
||||
## Directory
|
||||
|
||||
Let's look at some of the providers in detail. If you'd like to add a provider to the
|
||||
@@ -117,8 +237,30 @@ $ opencode auth login
|
||||
└
|
||||
```
|
||||
|
||||
This will ask you login with your Anthropic account in your browser. Now all the
|
||||
the Anthropic models should be available when you use the `/models` command.
|
||||
Here you can select the **Claude Pro/Max** option and it'll open your browser
|
||||
and ask you to authenticate.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ Anthropic
|
||||
│
|
||||
◆ Login method
|
||||
│ ● Claude Pro/Max
|
||||
│ ○ Create API Key
|
||||
│ ○ Manually enter API Key
|
||||
└
|
||||
```
|
||||
|
||||
Now all the the Anthropic models should be available when you use the `/models` command.
|
||||
|
||||
##### Using API keys
|
||||
|
||||
You can also select **Create API Key** if you don't have a Pro/Max subscription. It'll also open your browser and ask you to login to Anthropic and give you a code you can paste in your terminal.
|
||||
|
||||
Or if you already have an API key, you can select **Manually enter API Key** and paste it in your terminal.
|
||||
|
||||
---
|
||||
|
||||
@@ -185,6 +327,78 @@ the Anthropic models should be available when you use the `/models` command.
|
||||
|
||||
---
|
||||
|
||||
### DeepSeek
|
||||
|
||||
1. Head over to the [DeepSeek console](https://platform.deepseek.com/), create an account, and click **Create new API key**.
|
||||
|
||||
2. Run `opencode auth login` and select **DeepSeek**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ● DeepSeek
|
||||
│ ...
|
||||
└
|
||||
```
|
||||
|
||||
3. Enter your DeepSeek API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ DeepSeek
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ _
|
||||
└
|
||||
```
|
||||
|
||||
4. Run the `/models` command to select a DeepSeek model like _DeepSeek Reasoner_.
|
||||
|
||||
---
|
||||
|
||||
### Fireworks AI
|
||||
|
||||
1. Head over to the [Fireworks AI console](https://app.fireworks.ai/), create an account, and click **Create API Key**.
|
||||
|
||||
2. Run `opencode auth login` and select **Fireworks AI**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ● Fireworks AI
|
||||
│ ...
|
||||
└
|
||||
```
|
||||
|
||||
3. Enter your Fireworks AI API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ Fireworks AI
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ _
|
||||
└
|
||||
```
|
||||
|
||||
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
|
||||
|
||||
---
|
||||
|
||||
### GitHub Copilot
|
||||
|
||||
To use your GitHub Copilot subscription with opencode:
|
||||
@@ -290,6 +504,78 @@ In this example:
|
||||
|
||||
---
|
||||
|
||||
### Moonshot AI
|
||||
|
||||
To use Kimi K2 from Moonshot AI:
|
||||
|
||||
1. Head over to the [Moonshot AI console](https://platform.moonshot.ai/console), create an account, and click **Create API key**.
|
||||
|
||||
2. Run `opencode auth login` and select **Other**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ...
|
||||
│ ● Other
|
||||
└
|
||||
```
|
||||
|
||||
3. Enter `moonshot` as the provider ID.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ Other
|
||||
│
|
||||
◇ Enter provider id
|
||||
│ moonshot
|
||||
└
|
||||
```
|
||||
|
||||
4. Enter your Moonshot API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ sk-...
|
||||
└
|
||||
```
|
||||
|
||||
5. Configure Moonshot in your opencode config.
|
||||
|
||||
```json title="opencode.json" "\"moonshot\"" {5-15}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"moonshot": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "Moonshot AI",
|
||||
"options": {
|
||||
"baseURL": "https://api.moonshot.ai/v1"
|
||||
},
|
||||
"models": {
|
||||
"kimi-k2-0711-preview": {
|
||||
"name": "Kimi K2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
6. Run the `/models` command to select _Kimi K2_.
|
||||
|
||||
---
|
||||
|
||||
### Ollama
|
||||
|
||||
You can configure opencode to use local models through Ollama.
|
||||
@@ -435,8 +721,12 @@ https://platform.openai.com/api-keys
|
||||
}
|
||||
```
|
||||
|
||||
{ /*
|
||||
---
|
||||
|
||||
TODO: Test a model that actually works, currently getting errors form the API
|
||||
for Qwen non-thinking models.
|
||||
|
||||
### Cerebras
|
||||
|
||||
Cerebras offers fast inference with generous free tiers and competitive pricing.
|
||||
@@ -510,15 +800,15 @@ Cerebras offers fast inference with generous free tiers and competitive pricing.
|
||||
|
||||
6. Run the `/models` command to select a Cerebras model.
|
||||
|
||||
*/ }
|
||||
|
||||
---
|
||||
|
||||
### DeepSeek
|
||||
### Together AI
|
||||
|
||||
DeepSeek offers powerful reasoning models at competitive prices.
|
||||
1. Head over to the [Together AI console](https://api.together.ai), create an account, and click **Add Key**.
|
||||
|
||||
1. Head over to the [DeepSeek console](https://platform.deepseek.com/), create an account, and generate an API key.
|
||||
|
||||
2. Run `opencode auth login` and select **Other**.
|
||||
2. Run `opencode auth login` and select **Together AI**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
@@ -526,12 +816,12 @@ DeepSeek offers powerful reasoning models at competitive prices.
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ● Together AI
|
||||
│ ...
|
||||
│ ● Other
|
||||
└
|
||||
```
|
||||
|
||||
3. Enter `deepseek` as the provider ID.
|
||||
3. Enter your Together AI API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
@@ -539,286 +829,14 @@ DeepSeek offers powerful reasoning models at competitive prices.
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ Other
|
||||
│
|
||||
◇ Enter provider id
|
||||
│ deepseek
|
||||
└
|
||||
```
|
||||
|
||||
4. Enter your DeepSeek API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│ Together AI
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ sk-...
|
||||
│ _
|
||||
└
|
||||
```
|
||||
|
||||
5. Configure DeepSeek in your opencode config.
|
||||
|
||||
```json title="opencode.json" "deepseek" {5-17}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"deepseek": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "DeepSeek",
|
||||
"options": {
|
||||
"baseURL": "https://api.deepseek.com/v1"
|
||||
},
|
||||
"models": {
|
||||
"deepseek-reasoner": {
|
||||
"name": "DeepSeek Reasoner"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
6. Run the `/models` command to select a DeepSeek model.
|
||||
|
||||
---
|
||||
|
||||
### Moonshot AI (Kimi)
|
||||
|
||||
Moonshot AI offers the Kimi models with long context capabilities.
|
||||
|
||||
1. Head over to the [Moonshot AI console](https://platform.moonshot.cn/), create an account, and generate an API key.
|
||||
|
||||
2. Run `opencode auth login` and select **Other**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ...
|
||||
│ ● Other
|
||||
└
|
||||
```
|
||||
|
||||
3. Enter `moonshot` as the provider ID.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Select provider
|
||||
│ Other
|
||||
│
|
||||
◇ Enter provider id
|
||||
│ moonshot
|
||||
└
|
||||
```
|
||||
|
||||
4. Enter your Moonshot API key.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ sk-...
|
||||
└
|
||||
```
|
||||
|
||||
5. Configure Moonshot in your opencode config.
|
||||
|
||||
```json title="opencode.json" "moonshot" {5-17}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"moonshot": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "Moonshot AI",
|
||||
"options": {
|
||||
"baseURL": "https://api.moonshot.cn/v1"
|
||||
},
|
||||
"models": {
|
||||
"kimi-k2-0711-preview": {
|
||||
"name": "Kimi K2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
6. Run the `/models` command to select a Kimi model.
|
||||
|
||||
---
|
||||
|
||||
### Custom
|
||||
|
||||
To add any **OpenAI-compatible** provider that's not listed in `opencode auth login`:
|
||||
|
||||
:::tip
|
||||
You can use any OpenAI-compatible provider with opencode. Most modern AI providers offer OpenAI-compatible APIs.
|
||||
:::
|
||||
|
||||
1. Run `opencode auth login` and scroll down to **Other**.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◆ Select provider
|
||||
│ ...
|
||||
│ ● Other
|
||||
└
|
||||
```
|
||||
|
||||
2. Enter a unique ID for the provider.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
◇ Enter provider id
|
||||
│ myprovider
|
||||
└
|
||||
```
|
||||
|
||||
:::note
|
||||
Choose a memorable ID, you'll use this in your config file.
|
||||
:::
|
||||
|
||||
3. Enter your API key for the provider.
|
||||
|
||||
```bash
|
||||
$ opencode auth login
|
||||
|
||||
┌ Add credential
|
||||
│
|
||||
▲ This only stores a credential for myprovider - you will need configure it in opencode.json, check the docs for examples.
|
||||
│
|
||||
◇ Enter your API key
|
||||
│ sk-...
|
||||
└
|
||||
```
|
||||
|
||||
4. Create or update your `opencode.json` file in your project directory:
|
||||
|
||||
```json title="opencode.json" ""myprovider"" {5-15}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"myprovider": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "My AI ProviderDisplay Name",
|
||||
"options": {
|
||||
"baseURL": "https://api.myprovider.com/v1"
|
||||
},
|
||||
"models": {
|
||||
"my-model-name": {
|
||||
"name": "My Model Display Name"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here are the configuration options:
|
||||
|
||||
- **npm**: AI SDK package to use, `@ai-sdk/openai-compatible` for OpenAI-compatible providers
|
||||
- **name**: Display name in UI.
|
||||
- **models**: Available models.
|
||||
- **options.baseURL**: API endpoint URL.
|
||||
- **options.apiKey**: Optionally set the API key, if not using auth.
|
||||
- **options.headers**: Optionally set custom headers.
|
||||
|
||||
More on the advanced options in the example below.
|
||||
|
||||
5. Run the `/models` command and your custom provider and models will appear in the selection list.
|
||||
|
||||
---
|
||||
|
||||
##### Example
|
||||
|
||||
Here's an example setting the `apiKey` and `headers` options.
|
||||
|
||||
```json title="opencode.json" {9,11}
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"myprovider": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "My AI ProviderDisplay Name",
|
||||
"options": {
|
||||
"baseURL": "https://api.myprovider.com/v1",
|
||||
"apiKey": "{env:ANTHROPIC_API_KEY}",
|
||||
"headers": {
|
||||
"Authorization": "Bearer custom-token"
|
||||
}
|
||||
},
|
||||
"models": {
|
||||
"my-model-name": {
|
||||
"name": "My Model Display Name"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We are setting the `apiKey` using the `env` variable syntax, [learn more](/docs/config#env-vars).
|
||||
|
||||
#### Common Examples
|
||||
|
||||
**Together AI:**
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"together": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "Together AI",
|
||||
"options": {
|
||||
"baseURL": "https://api.together.xyz/v1"
|
||||
},
|
||||
"models": {
|
||||
"meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo": {
|
||||
"name": "Llama 3.2 11B Vision"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Fireworks AI:**
|
||||
|
||||
```json title="opencode.json"
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"fireworks": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "Fireworks AI",
|
||||
"options": {
|
||||
"baseURL": "https://api.fireworks.ai/inference/v1"
|
||||
},
|
||||
"models": {
|
||||
"accounts/fireworks/models/llama-v3p1-70b-instruct": {
|
||||
"name": "Llama 3.1 70B"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user