APIMODELSAPIMODELS
OpenClaw · personal AI assistant · custom provider

Use apimodels in OpenClaw

Add one custom provider to openclaw.json and OpenClaw runs on apimodels — Claude, GPT and Gemini behind a single pay-as-you-go key, no per-vendor subscriptions. About 3 minutes.

Configuration values you need

FieldValue
baseUrlhttps://api.apimodels.app/v1
apiopenai-completions
apiKeyYour apimodels API Key (reference it via an env var)
Model allowlistEvery model you want must be listed in the models array

Step 1 · Export your API key

export APIMODELS_API_KEY="sk_…your_apimodels_key…"

The config references it as ${APIMODELS_API_KEY}, keeping the key itself out of openclaw.json — that file gets pasted wholesale into help threads all the time; don’t let your key travel with it.

Step 2 · Add the provider to openclaw.json

// ~/.openclaw/openclaw.json
{
  "agents": {
    "defaults": {
      "model": { "primary": "apimodels/claude-opus-5-5" }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "apimodels": {
        "baseUrl": "https://api.apimodels.app/v1",
        "apiKey": "${APIMODELS_API_KEY}",
        "api": "openai-completions",
        "timeoutSeconds": 300,
        "models": [
          {
            "id": "claude-opus-5-5",
            "name": "Claude Opus 5.5",
            "reasoning": false,
            "input": ["text", "image"],
            "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
            "contextWindow": 200000,
            "maxTokens": 8192
          },
          {
            "id": "gpt-6.1-sol",
            "name": "GPT-6.1 Sol",
            "reasoning": false,
            "input": ["text", "image"],
            "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
            "contextWindow": 200000,
            "maxTokens": 8192
          },
          {
            "id": "gemini-3-pro-preview",
            "name": "Gemini 3 Pro",
            "reasoning": false,
            "input": ["text", "image"],
            "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
            "contextWindow": 200000,
            "maxTokens": 8192
          }
        ]
      }
    }
  }
}
  • Models are referenced as provider/model, e.g. apimodels/claude-opus-5-5 — that is what goes into agents.defaults.model.primary.
  • The models array is an allowlist: anything not listed fails with “model not allowed”. Add a model to the array before switching to it.
  • The cost fields only drive OpenClaw’s local usage display; actual billing is on your apimodels account — zeros are fine.
  • mode: "merge" keeps built-in providers alongside; switch to "replace" to use apimodels exclusively.

Step 3 · Sanity-check with curl, then restart OpenClaw

curl -s https://api.apimodels.app/v1/chat/completions \
  -H "Authorization: Bearer $APIMODELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 16,
    "messages": [{ "role": "user", "content": "Reply with exactly: ok" }]
  }'

A response containing "ok" means you are through — this hits the same baseUrl over the same OpenAI-compatible wire as the config. Then restart OpenClaw to pick up the change.

Troubleshooting

model not allowedThe model is not in the allowlist. Add it to the provider’s models array; the id must match our model name byte-for-byte.
401 / Invalid API keyThe env var is not visible to the OpenClaw process (restart it after editing your shell config), or the key is wrong. Verify the key alone with the curl above.
Tool calls stall / files never changeYou picked a model without tool capability. Use the three models in the example above — function calling is verified on all of them.
Prefer the Anthropic-native wireOpenClaw also supports api: "anthropic-messages" (our /v1/messages endpoint is live too). Unless you have a specific reason, stick with openai-completions — one provider entry covers Claude, GPT and Gemini together.