Inference APIs
Integrations/Coding agent

Use Inference APIs with opencode

Add Inference APIs to opencode as a custom OpenAI-compatible provider and use DeepSeek, GLM or Kimi models hosted in the United States, billed per token.

Settings

SettingValue
Base URLhttps://api.inferenceapis.com/v1 (also /openai/v1)
API keyFrom API Keys; send as Authorization: Bearer …
Chat model idsopenai/gpt-oss-120b, deepseek-ai/DeepSeek-V4-Flash, zai-org/GLM-5.3-Flash, meta-llama/Llama-3.3-70B-Instruct-Turboall models
Audio model idsopenai/whisper-large-v3 (transcription), hexgrad/Kokoro-82M (speech)

Which model

A large model for agent work: zai-org/GLM-5.3, deepseek-ai/DeepSeek-V4-Pro or moonshotai/Kimi-K2.7-Code. DeepSeek and GLM here run in the United States, so opencode's "models hosted in China" switch is not needed. Prices and measured speed: chat models.

Configuration

opencode.json (project root, or ~/.config/opencode/opencode.json)
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "inferenceapis": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Inference APIs",
      "options": {
        "baseURL": "https://api.inferenceapis.com/v1",
        "apiKey": "{env:INFERENCE_API_KEY}"
      },
      "models": {
        "zai-org/GLM-5.3": { "name": "GLM 5.3", "limit": { "context": 1000000, "output": 32768 } },
        "deepseek-ai/DeepSeek-V4-Pro": { "name": "DeepSeek V4 Pro", "limit": { "context": 1000000, "output": 32768 } },
        "deepseek-ai/DeepSeek-V4-Flash": { "name": "DeepSeek V4 Flash", "limit": { "context": 1000000, "output": 32768 } },
        "moonshotai/Kimi-K2.7-Code": { "name": "Kimi K2.7 Code", "limit": { "context": 262144, "output": 32768 } }
      }
    }
  }
}
Shell
export INFERENCE_API_KEY="your-key"
opencode            # then /models and pick inferenceapis/zai-org/GLM-5.3

Verify

Run /models inside opencode; the four models appear under "Inference APIs". Send "list the files here" to confirm a tool call works.

How this guide was checked

Configuration only The provider block follows opencode's documented custom-provider format (@ai-sdk/openai-compatible). We ran that AI SDK package against the live API on 2026-09-17, including streaming and tool calls, but did not run opencode itself end to end. If a step does not match what you see, tell us.

Gotchas

  • The model id in opencode is the provider id plus our model id: inferenceapis/zai-org/GLM-5.3.
  • Instead of the environment variable you can run /connect and paste the key.
  • Set limit.context to the model's real window so opencode compacts the conversation at the right time.
  • opencode resends the conversation each turn. The repeated part is served from cache and billed at the cached-input rate, about 80 to 98 percent below normal input, with nothing to configure.

If something fails

401 — key missing or wrong · 402 insufficient_balance — add credits on Billing · 404 model_not_found — check the id against the model list (aliases such as gpt-oss-120b work too) · 503 model_unavailable — the model is being enabled. Full details in the API docs.