---
name: inferspeed
description: Use InferSpeed (pay-per-token model API, OpenAI- and Anthropic-compatible) as the model backend for an agent or coding tool. Covers base URLs, auth, model and price discovery, a connection test, balance checks, topping up through your human, errors and retries.
version: 3
updated: 2026-10-15
---

# InferSpeed skill

Version 3, 2026-10-15. Source: https://inferspeed.ai/skill.md. Site index: https://inferspeed.ai/llms.txt.

InferSpeed is a pay-per-token model API with OpenAI- and Anthropic-compatible HTTP endpoints, billed
from a prepaid balance. Models on sale and live prices: https://inferspeed.ai/model-plaza (JSON: https://inferspeed.ai/api/v1/public/pricing).

## Safety rules for the agent

- The key belongs to your human. Never print it, log it, paste it into chat, or put it in a command
  line argument. Read it from the environment variable `INFERSPEED_API_KEY`.
- If `INFERSPEED_API_KEY` is not set, ask your human to create a key at https://inferspeed.ai/keys and
  export it. Do not ask them to paste the key to you.
- Ask your human before writing or changing any tool config file (for example
  `~/.claude/settings.json`, `~/.codex/config.toml`, `opencode.json`). Show them the file and the
  change first. Never write the key into a file that is committed or shared.

## Settings

| Setting                       | Value                                                               |
| ----------------------------- | ------------------------------------------------------------------- |
| OpenAI-compatible base URL    | `https://api.inferspeed.ai/v1`                                       |
| Anthropic-compatible base URL | `https://api.inferspeed.ai` (clients add `/v1/messages`)             |
| Auth header                   | `Authorization: Bearer $INFERSPEED_API_KEY` (`x-api-key` also works) |
| Model IDs                     | Any public model; list: `GET https://inferspeed.ai/api/v1/public/pricing` |
| Models per key                | Every live model; `GET https://api.inferspeed.ai/v1/models`          |

Use only the two base URLs above; there is no other API version or host (no `/v2`, no `/v3`).

Endpoints: `POST /v1/chat/completions` (OpenAI Chat Completions), `POST /v1/responses` (OpenAI
Responses, Codex CLI), `POST /v1/messages` (Anthropic Messages, Claude Code), `GET /v1/models`.

One API key calls every live model (`glm-5.3`, `kimi-k3`, `MiniMax-M3`, ...): name the model in the
request, and it is billed at that model's price. `glm-5.3-flash` is served on `POST /v1/chat/completions`
only. Examples use `glm-5.3`; put any ID from `GET /v1/models` in its place.

Reasoning models (such as `glm-5.3` and `kimi-k3`) think before answering; the reasoning counts as
output tokens. Do not set `max_tokens` very low or the answer can come back empty. Limits and
context details: https://inferspeed.ai/developers.md

## Discover models and prices

- Models this key can call (needs the key):
  `GET https://api.inferspeed.ai/v1/models` returns an OpenAI-style list; use the `id` values.
- Prices (public, no key): `GET https://inferspeed.ai/api/v1/public/pricing`. The body is
  `{"code": 0, "data": {...}}`; `data.models[]` has `id`, `name`, `protocols` (when verified),
  `price` and `list_price` with `input`, `output`, `cache_read`, `cache_write` in USD per 1M tokens
  (`data.unit` is `per_1m_tokens`). Fields that are not priced are left out.

## Test the connection

This prints the HTTP status and the model IDs, never the key:

```
curl -sS https://api.inferspeed.ai/v1/models \
  -H "Authorization: Bearer $INFERSPEED_API_KEY" \
  -w '\nHTTP %{http_code}\n'
```

200 means the key works. 401 means the key is wrong or disabled; 403 means it is blocked (see
errors below).

## Configure a coding tool

Exact config blocks for Codex CLI, Claude Code, OpenCode, OpenClaw and other OpenAI-compatible
tools: https://inferspeed.ai/developers.md. The Claude Code and Codex CLI configs were verified
against production on 2026-10-14 with Claude Code 2.1.296 and Codex CLI 0.162.1.

Or, with your human's approval, run the installer. It reads the key from `INFERSPEED_API_KEY`, prints
the one file it will change with a diff (secrets hidden), backs the file up, writes it, then tests
the connection. Read it first: https://inferspeed.ai/setup.sh

```
curl -fsSL https://inferspeed.ai/setup.sh | sh -s -- claude --dry-run   # show only, write nothing
curl -fsSL https://inferspeed.ai/setup.sh | sh -s -- claude             # or codex, opencode, openclaw
curl -fsSL https://inferspeed.ai/setup.sh | sh -s -- claude --model kimi-k3   # pick the model
```

Without `--model` the installer uses the first model the key can call (`GET /v1/models`).

For `openclaw` it only prints the settings to add by hand.

## Check balance and usage

`GET https://api.inferspeed.ai/v1/usage` with the same `Authorization` header. Fields to read:

- `remaining` and `unit` (`"USD"`): what this key can still spend. For a key with its own spend
  cap, `quota.limit`, `quota.used` and `quota.remaining`; otherwise `balance` is the account's
  prepaid balance.
- `usage.today` and `usage.total` for this key: `requests`, `input_tokens`, `output_tokens`,
  `cache_read_tokens`, `cache_creation_tokens`, `total_tokens`, and `actual_cost` (USD charged).
- Optional query: `days=1..90` adds `daily_usage`; `start_date` / `end_date` (`YYYY-MM-DD`) set the
  range of `model_stats`.

## Top up when the balance is low

When the balance is low or a request fails with 403 `INSUFFICIENT_BALANCE`, call
`POST https://inferspeed.ai/api/v1/billing/topup` and give the URL to your user. You never see
card details; your human pays on a Stripe page (card, Apple Pay, Google Pay).

```
curl -sS https://inferspeed.ai/api/v1/billing/topup \
  -H "Authorization: Bearer $INFERSPEED_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <any unique string per top-up>" \
  -d '{"amount_usd": 10}'
```

The body is `{"code": 0, "data": {...}}`. Read from `data`:

- `payment_url`: the payment page. Send it to your human, or show `qr_code_png` (a
  `data:image/png` QR of the same URL). `message_for_user` is a ready-to-send sentence.
- `id`, `status` (`pending`), `amount_usd`, `credit_usd` (what lands in the balance, bonus
  included), `expires_at` (the link closes then; create a new one after that).
- `status_url`: poll it with the same header every 5-10 seconds.

`GET https://inferspeed.ai/api/v1/billing/topup/{id}` returns `status`: `pending` (not paid yet),
`paid` (being credited), `completed` (credited; `balance_usd` is the new balance), or `expired`,
`cancelled`, `failed` (make a new top-up). When it is `completed`, retry the request that failed.

`GET https://inferspeed.ai/api/v1/billing/balance` returns `balance_usd`. Both billing endpoints
work at zero balance. Rules: ask your human how much to add if they have not said; never create
more than one open top-up at a time; amounts outside the allowed range fail with 400 and a reason.
A person can also top up at https://inferspeed.ai/purchase.

## When a request fails

Branch on the status code and the error code (`code`, or `error.code` / `error.type`), not on the
message text.

- 400: the request is invalid, or (`model_not_available`) no live model answers to the model name:
  pick one from `available_models`. The same body fails again. Agent default names (`claude-*`,
  `gpt-*`, `codex-*`, `o*`, `gemini-*`, `grok-*`) never get this: they are routed to a live model,
  named in the response's `model` field and billed at its price (`X-Model-Strict: 1` turns that off).
- 401: the key is missing, wrong or disabled. Stop and ask your human.
- 403 `INSUFFICIENT_BALANCE`: the balance is used up. Retrying will not help. Create a top-up
  (`POST https://inferspeed.ai/api/v1/billing/topup`, see above), give the `payment_url` to your
  human, wait for `completed`, then retry. The error body also has `topup_url` (the console page)
  and `topup_api`. Other 403s (expired key, IP not allowed): stop and ask.
- 403 `API_KEY_QUOTA_EXHAUSTED` (`error.code` `insufficient_quota`): the spend cap on this key
  is reached. Stop and ask your human to raise it. Retrying will not help.
- 403 `permission_denied` with `error.type` `billing_error`: the balance ran out while the
  request waited. Same as `INSUFFICIENT_BALANCE`, but the body has no `topup_url`.
- 429 `USAGE_LIMIT_EXCEEDED`, or any 429 with an `x-should-retry: false` header: a spend cap on
  this key (5-hour, daily or 7-day) or an allowance is used up until its window resets
  (`Retry-After`, when set, is the seconds until then). Retrying soon will not help; stop and ask
  your human.
- Any other 429: rate limited or at capacity. Wait `Retry-After` seconds, then retry with backoff.
- 524, or a non-streaming request cut off after about 100 seconds: the response took too long to
  arrive in one piece. Retry once with `"stream": true` (or a lower `max_tokens`); the same
  non-streaming request will hit the same limit. Use `"stream": true` for long outputs.
- 503 and other 5xx: temporary. Retry with backoff; https://inferspeed.ai/status shows live checks.

Full error table: https://inferspeed.ai/developers.md

## More

- Agent setup: https://inferspeed.ai/agents.md
- API page: https://inferspeed.ai/developers.md
- Site index: https://inferspeed.ai/llms.txt
- Installer: https://inferspeed.ai/setup.sh
- Prices (JSON): https://inferspeed.ai/api/v1/public/pricing
