Skip to content

Providers

OpenCode uses the AI SDK and Models.dev to support 75+ LLM providers, including local models. This page covers how to connect providers and configure them.

Connecting a Provider

Use the /connect command inside the OpenCode TUI to add a provider:

/connect

This opens a provider selection list. Choose your provider, then:

  1. Authenticate (OAuth, API key, or subscription login)
  2. Paste your API key when prompted
  3. Run /models to select a model
/models

OpenCode Zen

Recommended for beginners. OpenCode Zen offers curated models that have been tested and verified by the OpenCode team.

  1. Run /connect and select OpenCode Zen
  2. Sign in at opencode.ai/auth and create an API key
  3. Paste your API key
  4. Run /models to see recommended models

OpenCode Go

A low-cost subscription plan with reliable access to popular open coding models.

Anthropic (Claude)

/connect
# Select "Anthropic"
# Choose "Claude Pro/Max" for subscription login, or "Manually enter API Key"

After authentication, run /models to access all Claude models.

WARNING

Anthropic explicitly prohibits using Claude Pro/Max subscriptions through third-party plugins. Use official authentication methods only.

OpenAI (ChatGPT)

/connect
# Select "OpenAI"
# Choose "ChatGPT Plus/Pro" for subscription login, or "Manually enter API Key"

We recommend signing up for ChatGPT Plus or Pro for the best experience.

GitHub Copilot

/connect
# Select "GitHub Copilot"
# Navigate to github.com/login/device and enter the code shown

Some models may require a Pro+ subscription.

Google Vertex AI

Set environment variables:

bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
export GOOGLE_CLOUD_PROJECT=your-project-id
export VERTEX_LOCATION=global   # optional, defaults to "global"

Then run /connect and select Google Vertex AI.

Azure OpenAI

bash
export AZURE_RESOURCE_NAME=your-resource-name

Run /connect, select Azure, enter your API key. The deployment name must match the model name.

Local Models

Ollama

Configure in opencode.json:

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 with Ollama, try increasing num_ctx to 16k–32k.

LM Studio

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)"
        }
      }
    }
  }
}

llama.cpp

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "qwen3-coder:a3b": {
          "name": "Qwen3-Coder: a3b-30b (local)",
          "limit": {
            "context": 128000,
            "output": 65536
          }
        }
      }
    }
  }
}

Custom Provider

For any OpenAI-compatible provider not in the /connect list:

  1. Run /connect and scroll to Other
  2. Enter a unique provider ID (e.g., myprovider)
  3. Enter your API key
  4. Add configuration to opencode.json:
json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "myprovider": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "My Provider",
      "options": {
        "baseURL": "https://api.myprovider.com/v1"
      },
      "models": {
        "my-model": {
          "name": "My Model",
          "limit": {
            "context": 200000,
            "output": 65536
          }
        }
      }
    }
  }
}

Key configuration fields:

FieldDescription
npmAI SDK package. Use @ai-sdk/openai-compatible for /v1/chat/completions, or @ai-sdk/openai for /v1/responses
nameDisplay name in the UI
options.baseURLAPI endpoint URL
options.apiKeyAPI key (use {env:VAR} syntax recommended)
options.headersCustom request headers
modelsMap of model IDs to their config
models.*.limit.contextMax input tokens
models.*.limit.outputMax output tokens

Provider Management

Disable Providers

Prevent specific providers from loading:

json
{
  "disabled_providers": ["openai", "gemini"]
}

Enable Only Specific Providers

Restrict to an allowlist:

json
{
  "enabled_providers": ["anthropic", "openai"]
}

disabled_providers takes priority over enabled_providers.

Troubleshooting

  • Check auth setup: Run opencode auth list to verify credentials
  • Custom providers: Ensure the provider ID in /connect matches the ID in your config
  • Correct npm package: Use @ai-sdk/openai-compatible for most providers, @ai-sdk/openai for /v1/responses endpoints
  • Base URL: Verify the API endpoint is correct

Further Reading

Released under the GPLv3 License.