Skip to main content
OpenCode uses an AI SDK, so any OpenAI-compatible provider can be added via opencode.json. Credentials are stored separately using the /connect command.

Configuration Variations

API key from the environment variable (without /connect):
Via the Responses API — replace npm with @ai-sdk/openai; OpenCode will use /v1/responses. Useful for GPT-5.x models when you want a reasoning summary. For most users, @ai-sdk/openai-compatible (Chat Completions) is sufficient.

Troubleshooting

  • The provider does not appear in /models — The IDs in /connect and opencode.json are different, or the JSON Invalid. Check opencode auth list.
  • 401 — No key has been saved for that ID; repeat /connect.
  • 404 model_not_found — The models key must match the exact slug from GET /v1/models.