Skip to content

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

You can customize the providers through the provider section in your OpenCode config.

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

To use Amazon Bedrock with OpenCode:

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

  2. Configure authentication:

Environment Variables:

# Using AWS access keys
AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode

# Using an AWS profile
AWS_PROFILE=my-profile opencode

# Using a 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 region (e.g. us-east-1, eu-west-1)
  • profile - Named AWS profile from ~/.aws/credentials
  • endpoint - Custom URL for a VPC endpoint (alias of 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

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

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.

302.AI

  1. Create an account at 302.AI and generate an API key.
  2. Run /connect and search for 302.AI.
  3. Enter your API key.
  4. Run /models to select a model.

Atomic Chat

Atomic Chat is a desktop app that runs local models behind an OpenAI-compatible server (127.0.0.1:1337). Configure it directly in opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "atomic-chat": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Atomic Chat (local)",
      "options": {
        "baseURL": "http://127.0.0.1:1337/v1"
      },
      "models": {
        "<your-model-id>": {}
      }
    }
  }
}

Replace <your-model-id> with a model id returned by the server, then run /models to select it.

Azure Cognitive Services

  1. Create an Azure OpenAI resource and deploy a model at Azure AI — the deployment name must match the model name.
  2. Run /connect and search for Azure Cognitive Services.
  3. Enter your API key.
  4. Set the AZURE_COGNITIVE_SERVICES_RESOURCE_NAME environment variable to your resource name.
  5. Run /models to select your deployed model.

Baseten

  1. Create an account at Baseten and generate an API key.
  2. Run /connect and search for Baseten.
  3. Enter your API key.
  4. Run /models to select a model.

Cloudflare Workers AI

  1. Grab your Account ID and create an API token under Workers AI in the Cloudflare dashboard.
  2. Run /connect and search for Cloudflare Workers AI.
  3. Enter your Account ID and API token.
  4. Run /models to select a model.

Cortecs

  1. Create an account at Cortecs and generate an API key.
  2. Run /connect and search for Cortecs.
  3. Enter your API key.
  4. Run /models to select a model like Kimi K2 Instruct.

Deep Infra

  1. Create an account at Deep Infra and generate an API key.
  2. Run /connect and search for Deep Infra.
  3. Enter your API key.
  4. Run /models to select a model.

DigitalOcean

  1. Sign in to your DigitalOcean account.
  2. Run /connect and search for DigitalOcean.
  3. Choose Login with DigitalOcean (OAuth) or paste a Model Access Key.
  4. Run /models to select a model — Inference Routers appear as router:<name>.

FrogBot

  1. Create an account at FrogBot and generate an API key.
  2. Run /connect and search for FrogBot.
  3. Enter your API key.
  4. Run /models to select a model.

GMI Cloud

  1. Create an API key in the GMI Cloud console.
  2. Run /connect and search for GMI Cloud.
  3. Enter your API key.
  4. Run /models to select a model.

Helicone

Helicone provides LLM logging, monitoring, and an AI Gateway that routes requests based on the model.

  1. Create an account at Helicone and generate an API key.
  2. Run /connect and search for Helicone.
  3. Enter your API key.
  4. Run /models to select a model.

IO.NET

  1. Create an account at IO.NET and generate an API key.
  2. Run /connect and search for IO.NET.
  3. Enter your API key.
  4. Run /models to select a model.

llama.cpp

llama.cpp serves local models through its OpenAI-compatible llama-server.

  1. Start the local server: llama-server --port 8080.
  2. Add the provider to your opencode.json, pointing at the local endpoint:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://localhost:8080/v1"
      },
      "models": {
        "qwen3-coder:a3b": {}
      }
    }
  }
}
  1. Run /models to select your local model.

LLM Gateway

  1. Create an API key in the LLM Gateway dashboard.
  2. Run /connect and search for LLM Gateway.
  3. Enter your API key.
  4. Run /models to select a model — many models are preloaded by default.

MiniMax

  1. Create an account at MiniMax and generate an API key.
  2. Run /connect and search for MiniMax.
  3. Enter your API key.
  4. Run /models to select a model like M2.1.
  1. Create a shared Endpoint for your model and generate a proxy token.
  2. Join the token ID and secret with a period, e.g. wk-<id>.ws-<secret>.
  3. Run /connect, search for Modal, and enter the combined token.
  4. Run /models to select one of the endpoints in your workspace.

Moonshot AI

  1. Create an account at the Moonshot AI console and create an API key.
  2. Run /connect and search for Moonshot AI.
  3. Enter your API key.
  4. Run /models to select a model like Kimi K2.

Nebius Token Factory

  1. Create an account at Nebius Token Factory and click Add Key.
  2. Run /connect and search for Nebius Token Factory.
  3. Enter your API key.
  4. Run /models to select a model like Kimi K2 Instruct.

Ollama Cloud

  1. Sign in or create an account at ollama.com.
  2. Go to Settings → Keys and create an API key.
  3. Run /connect and search for Ollama Cloud.
  4. Enter your API key.
  5. Run /models to select a cloud model.

OVHcloud AI Endpoints

  1. Create an API key in the Public Cloud AI Endpoints section of the OVHcloud manager.
  2. Run /connect and search for OVHcloud AI Endpoints.
  3. Enter your API key.
  4. Run /models to select a model like gpt-oss-120b.

Poolside

  1. Sign in at Poolside, open the API Keys tab, and click New key.
  2. Run /connect and search for Poolside.
  3. Enter your API key.
  4. Run /models to select a model.

SAP AI Core

  1. Navigate to your SAP AI Core service instance in the SAP BTP Cockpit and create a service key.
  2. Run /connect and search for SAP AI Core.
  3. Paste the service key JSON.
  4. Run /models to select a model.

Scaleway

  1. Generate an API key in the IAM settings of the Scaleway console.
  2. Run /connect and search for Scaleway.
  3. Enter your API key.
  4. Run /models to select a model like gpt-oss-120b.

SCX.ai

  1. Create an account on the SCX.ai platform and generate an API key.
  2. Run /connect and search for SCX.ai.
  3. Enter your API key.
  4. Run /models to select a model like GLM-5.2.

Snowflake Cortex

Frontier models served inside the Snowflake perimeter; tool calling support is limited to the Claude and OpenAI families.

  1. Create an account at Snowflake.
  2. Run /connect and search for Snowflake Cortex.
  3. Select Login with Snowflake (External Browser) and complete sign-in in your browser, or paste a Programmatic Access Token.
  4. Run /models to select a model.

STACKIT

  1. Create an auth token for your project under AI Model Serving in the STACKIT Portal.
  2. Run /connect and search for STACKIT.
  3. Enter your auth token.
  4. Run /models to select a model like Qwen3-VL 235B.

Venice AI

  1. Create an account at Venice AI and generate an API key.
  2. Run /connect and search for Venice AI.
  3. Enter your API key.
  4. Run /models to select a model like Llama 3.3 70B.

Vercel AI Gateway

Access models from many providers through one unified endpoint.

  1. Create an API key under AI Gateway in the Vercel dashboard.
  2. Run /connect and search for Vercel AI Gateway.
  3. Enter your API key.
  4. Run /models to select a model.

xAI

  1. Create an account at the xAI console and generate an API key, or plan to authenticate with a SuperGrok subscription.
  2. Run /connect and search for xAI.
  3. Enter your API key, or select SuperGrok Subscription to log in via device code.
  4. Run /models to select a Grok model.

Z.AI

  1. Create an account at the Z.AI API console and create a new API key.
  2. Run /connect and search for Z.AI — pick Z.AI Coding Plan if you subscribe to the GLM Coding Plan.
  3. Enter your API key.
  4. Run /models to select a model like GLM-4.7.

ZenMux

  1. Create an API key in the ZenMux dashboard.
  2. Run /connect and search for ZenMux.
  3. Enter your API key.
  4. Run /models to select a model — many models are preloaded by default.

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

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