Connect your tools

OpenCode

Add Kontinent AI to OpenCode as a custom provider in opencode.json. Use Claude, GPT and Gemini models through the chat completions endpoint.

Or let your agent do it

Paste the prompt into your coding agent. The agent writes the configuration and tests it.

OpenCode can send OpenAI chat completions requests to a custom provider. Kontinent AI serves that format at https://api.kontinentai.com/v1/chat/completions, for Claude, GPT and Gemini models.

Before you start, make sure that you have:

  • OpenCode, installed.
  • A Kontinent AI key. See Quickstart.
  • Balance from a top-up or a redemption code. OpenCode sends prompts that are too long for the starter balance.

1. Set the key

export KONTINENT_API_KEY="sk-kont-..."

Put this line in your shell profile, for example ~/.zshrc, so that each new shell has the key.

2. Add the provider

Open ~/.config/opencode/opencode.json. If the file does not exist, create it. Add the kontinent provider:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "kontinent": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Kontinent AI",
      "options": {
        "baseURL": "https://api.kontinentai.com/v1",
        "apiKey": "{env:KONTINENT_API_KEY}"
      },
      "models": {
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
        "claude-opus-5-5": { "name": "Claude Opus 5.5" },
        "claude-haiku-4-5-20251001": { "name": "Claude Haiku 4.5" },
        "gpt-5.5": { "name": "GPT-5.5" },
        "gemini-3.1-pro-preview": { "name": "Gemini 3.1 Pro" },
        "gemini-3.5-flash": { "name": "Gemini 3.5 Flash" }
      }
    }
  },
  "model": "kontinent/claude-sonnet-5-5"
}
KeyWhat it does
npmThe package that OpenCode uses to send chat completions requests
options.baseURLOur API. The package adds /chat/completions to it
options.apiKey{env:KONTINENT_API_KEY} reads the key from your environment
modelsThe model ids that OpenCode shows. Each key must be a model id from the list on this page
modelThe model that OpenCode selects when it starts, as provider/model

To put the provider in one project only, put the same content in opencode.json at the root of the project. Do not put the key itself in that file.

3. Make sure that the connection works

Send one small request with curl:

curl -sS -w '\n%{http_code}\n' https://api.kontinentai.com/v1/chat/completions \
  -H "Authorization: Bearer $KONTINENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-4-5-20251001", "max_tokens": 16, "messages": [{"role": "user", "content": "Say OK."}]}'

A JSON response that ends with 200 shows that the key and the URL are correct. Then do these steps:

  1. Run opencode models kontinent. OpenCode shows the models from your file.
  2. Run opencode run -m kontinent/claude-haiku-4-5-20251001 "Say OK.". OpenCode prints the answer.

Models

These models work on the chat completions endpoint. This list comes from our model catalogue. You can add each of them to the models object:

  • claude-opus-5-5
  • claude-opus-5
  • claude-sonnet-5-5
  • claude-sonnet-5
  • claude-haiku-4-5-20251001
  • claude-fable-5-1
  • gpt-5.5
  • gpt-6.1-sol
  • gpt-5
  • gemini-3.1-pro-preview
  • gemini-3.5-flash
  • glm-5.3
  • qwen3.8-max
  • deepseek-v4.1-flash

Costs and limits

  • OpenCode streams its responses. We record the cost of each request, and the dashboard shows it.
  • Each request counts toward the limit of 60 requests a minute for each key.
  • The file above has no limit object for each model. If you add one, OpenCode needs context and output. The context_window field of GET /v1/models gives the context window of each model.

Problems

ProblemWhat to do
401Make sure that the shell that starts OpenCode has KONTINENT_API_KEY
402Your balance is too low. Top up on the balance page
400 that says is not served on /v1/chat/completionsRemove that model from the models object
404 that names a modelMake sure that each key in models is a model id from the list on this page

The OpenCode documentation for custom providers is at opencode.ai.