Set up OpenCode with InferSpeed: OpenCode API key and provider config

Add an inferspeed provider to opencode.json, put your key in the INFERSPEED_API_KEY environment variable, then pick inferspeed/glm-5.3. OpenCode uses the OpenAI Chat Completions endpoint, and you pay per token.

The config blocks match developers.md (checked 2026-10-19).

Setup

1. Create a key at https://inferspeed.ai/keys and put it in an environment variable (in ~/.zshrc or ~/.bashrc, not in a project file):

export INFERSPEED_API_KEY="sk-****"

2. Write this into opencode.json at the project root, or merge it into ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "inferspeed": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "InferSpeed",
      "options": {
        "baseURL": "https://api.inferspeed.ai/v1",
        "apiKey": "{env:INFERSPEED_API_KEY}"
      },
      "models": {
        "glm-5.3": {
          "name": "glm-5.3"
        }
      }
    }
  }
}

"apiKey": "{env:INFERSPEED_API_KEY}" makes OpenCode read the key from the environment, so the key never appears in the config file.

Check it works

opencode run -m inferspeed/glm-5.3 "reply with the word ok"

Common errors

ErrorCauseFix
400 model_not_availableThe model name could not be routed (strict mode X-Model-Strict: 1, or no live routing target; see Model routing in developers.md)available_models in the response lists the models this key can call; use one of them
403 INSUFFICIENT_BALANCEThe balance is used upTop up, then retry

Prices (USD per 1M tokens)

ModelInputOutputCache readOfficial price (input / output)
glm-5.3$0.84$2.64$0.156$1.40 / $4.40

All models and live prices: https://inferspeed.ai/model-plaza

FAQ

Can I use Kimi?
One key calls every live model (GET /v1/models lists the models your key can call); use the model ID kimi-k3. This page only gives the config for glm-5.3.

What are the default limits?
30 requests per minute and 5 concurrent requests for new accounts, across all keys of the account.