Skip to content

Providers

Providers

Using any LLM provider in OpenCode.

OpenCode uses the AI SDK and Models.dev to support 75+ LLM providers and it supports running local models.

To add a provider you need to:

  1. Add the API keys for the provider using the /connect command.
  2. Configure the provider in your OpenCode config.

Credentials

When you add a provider’s API keys with the /connect command, they are stored in ~/.local/share/opencode/auth.json.


Config

// Provider 配置基础格式 You can customize the providers through the provider section in your OpenCode config.

// 自定义 Base URL opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "baseURL": "https://api.anthropic.com/v1"
      }
    }
  }
}

OpenCode Zen

OpenCode Zen is a list of models provided by the OpenCode team that have been tested and verified to work well with OpenCode.

[!TIP] If you are new, we recommend starting with OpenCode Zen.

  1. Run the /connect command in the TUI, select OpenCode Zen, and head to opencode.ai/auth.
  2. Sign in, add your billing details, and copy your API key.
  3. Paste your API key.
  4. Run /models in the TUI to see the list of models we recommend.

OpenCode Go

OpenCode Go is a low cost subscription plan that provides reliable access to popular open coding models.

  1. Run the /connect command in the TUI, select OpenCode Go.
  2. Sign in, add your billing details, and copy your API key.
  3. Paste your API key.
  4. Run /models in the TUI to see the list of models.

Directory

Anthropic

  1. Run /connect and select Anthropic.
  2. Select Claude Pro/Max option or Manually enter API Key.
  3. Run /models to see available models.

[!NOTE] Anthropic explicitly prohibits using Claude Pro/Max subscription with third-party tools. Previous versions of OpenCode bundled plugins for this but that is no longer the case as of 1.3.0.

OpenAI

  1. Run /connect and select OpenAI.
  2. Select ChatGPT Plus/Pro or Manually enter API Key.
  3. Run /models to see available models.

Amazon Bedrock

// Amazon Bedrock 配置 To use Amazon Bedrock with OpenCode:

  1. Request access to models in the Amazon Bedrock console.

  2. Configure authentication:

Environment Variables:

# 使用 AWS Access Keys
AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode

# 使用 AWS Profile
AWS_PROFILE=my-profile opencode

# 使用 Bedrock Bearer Token
AWS_BEARER_TOKEN_BEDROCK=XXX opencode

Configuration File (Recommended): opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "amazon-bedrock": {
      "options": {
        "region": "us-east-1",
        "profile": "my-aws-profile"
      }
    }
  }
}

Available options:

  • region - AWS 区域(如 us-east-1, eu-west-1
  • profile - ~/.aws/credentials 中的 AWS 命名配置文件
  • endpoint - VPC 端点的自定义 URL(baseURL 的别名)

Azure OpenAI

  1. Create an Azure OpenAI resource in the Azure portal.
  2. Deploy a model in Azure AI Foundry.
  3. Run /connect and search for Azure.
  4. Enter your API key.
  5. Set your resource name as an environment variable:
AZURE_RESOURCE_NAME=XXX opencode

[!NOTE] If you encounter “I cannot assist with that request” errors, try changing the content filter from DefaultV2 to Default.

Google Vertex AI

  1. Enable Vertex AI API in your Google Cloud project.
  2. Set required environment variables:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
GOOGLE_CLOUD_PROJECT=your-project-id
VERTEX_LOCATION=global
  1. Run /models to select a model.

Ollama

// Ollama 本地模型配置 opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "llama2": {
          "name": "Llama 2"
        }
      }
    }
  }
}

[!TIP] If tool calls aren’t working, try increasing num_ctx in Ollama. Start around 16k - 32k.

LM Studio

// LM Studio 本地模型配置 opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LM Studio (local)",
      "options": {
        "baseURL": "http://127.0.0.1:1234/v1"
      },
      "models": {
        "google/gemma-3n-e4b": {
          "name": "Gemma 3n-e4b (local)"
        }
      }
    }
  }
}

OpenRouter

  1. Create an API key in the OpenRouter dashboard.
  2. Run /connect and search for OpenRouter.
  3. Enter your API key.
  4. Run /models to select a model.
{
  "provider": {
    "openrouter": {
      "models": {
        "somecoolnewmodel": {}
      }
    }
  }
}

DeepSeek

  1. Create an account at DeepSeek console.
  2. Create a new API key.
  3. Run /connect and search for DeepSeek.
  4. Enter your API key.
  5. Run /models to select a model like DeepSeek V4 Pro.

GitLab Duo

[!EXPERIMENTAL] GitLab Duo support in OpenCode is experimental.

OpenCode integrates with the GitLab Duo Agent Platform.

License requirements:

  • Premium or Ultimate GitLab subscription
  • Available on GitLab.com and GitLab Self-Managed
  1. Run /connect and select GitLab.
  2. Choose OAuth or Personal Access Token.
  3. Run /models to see available models.

Three Claude-based models are available:

  • duo-chat-haiku-4-5 (Default) - Fast responses
  • duo-chat-sonnet-4-5 - Balanced performance
  • duo-chat-opus-4-5 - Most capable

GitHub Copilot

  1. Run /connect and search for GitHub Copilot.
  2. Navigate to github.com/login/device and enter the code.
  3. Run /models to select the model.

[!NOTE] Some models might need a Pro+ subscription.

Cloudflare AI Gateway

  1. Create a gateway in Cloudflare dashboard (AI > AI Gateway).
  2. Run /connect and search for Cloudflare AI Gateway.
  3. Enter Account ID, Gateway ID, and API token.
  4. Run /models to select a model.

Hugging Face

  1. Create a token with inference.serverless.write permission.
  2. Run /connect and search for Hugging Face.
  3. Enter your token.
  4. Run /models to select a model.

NVIDIA

NVIDIA provides access to Nemotron models and other open models through build.nvidia.com.

  1. Generate an API key at build.nvidia.com.
  2. Run /connect and search for NVIDIA.
  3. Enter your API key.
  4. Run /models to select a model.

On-Prem / NIM:

{
  "provider": {
    "nvidia": {
      "options": {
        "baseURL": "http://localhost:8000/v1"
      }
    }
  }
}

Groq

  1. Create an API key at Groq console.
  2. Run /connect and search for Groq.
  3. Enter the API key.
  4. Run /models to select a model.

Cerebras

  1. Create an account at Cerebras console.
  2. Generate an API key.
  3. Run /connect and search for Cerebras.
  4. Run /models to select a model like Qwen 3 Coder 480B.

Together AI

  1. Create an account at Together AI.
  2. Generate an API key.
  3. Run /connect and search for Together AI.
  4. Run /models to select a model.

Fireworks AI

  1. Create an account at Fireworks AI console.
  2. Create an API key.
  3. Run /connect and search for Fireworks AI.
  4. Run /models to select a model.

Cohere

  1. Create an account and get an API key from the Cohere dashboard.
  2. Run /connect and search for Cohere.
  3. Enter your API key.
  4. Run /models to select a model.

Other Providers

OpenCode supports 75+ providers including:

  • 302.AI
  • Atomic Chat
  • Azure Cognitive Services
  • Baseten
  • Cloudflare Workers AI
  • Cortecs
  • Deep Infra
  • DigitalOcean
  • FrogBot
  • IO.NET
  • MiniMax
  • Moonshot AI
  • Nebius Token Factory
  • Ollama Cloud
  • SAP AI Core
  • Scaleway
  • Venice AI
  • Vercel AI Gateway
  • xAI
  • Z.AI
  • ZenMux

Custom provider

// 自定义 Provider 配置示例 opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "custom-provider": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Custom Provider",
      "options": {
        "baseURL": "https://api.example.com/v1"
      },
      "models": {
        "model-id": {
          "name": "Custom Model Name"
        }
      }
    }
  }
}

Troubleshooting

Provider not loading

  1. Check if API key is set: opencode debug config
  2. Verify environment variables are set correctly
  3. Check if provider supports your region

Authentication errors

  1. Verify API key is correct
  2. Check if subscription is active
  3. Ensure required scopes are granted

Rate limits

Consider using:

  • A proxy/gateway with rate limiting (Cloudflare AI Gateway, Helicone)
  • Provider-specific rate limit configurations
  • Multiple provider accounts