Kimi API quickstart: first call with curl or the Anthropic SDK
This Kimi API quickstart takes you from a fresh account to a working Kimi K3 response in about five minutes: one base URL, one x-api-key header, one namespaced model ID. Kimi speaks the Anthropic Messages protocol on the apiToken.sale router, so the official Anthropic SDK works with a single base_url change. The same prepaid key and balance also cover Claude, GPT and Gemini.
·
Your first Kimi request in three steps
The fastest path to a first Kimi response is a single POST to https://router.apitoken.sale/v1/messages with your apiToken.sale key in the x-api-key header and a kimi/* model ID in the body. There is no new SDK and no adapter layer — the endpoint speaks the Anthropic Messages protocol, so any client that already talks to Claude can talk to Kimi. Usage settles against the same prepaid balance as your Claude, GPT and Gemini traffic.
- 01Create a free account and generate one API key — it looks like sk-pool-… and already covers the supported Claude, GPT, Gemini and Kimi models.
- 02Top up any whole-dollar amount by card or crypto; Kimi needs no separate plan and no per-provider balance.
- 03Export the key as APITOKEN_API_KEY and send the request below. A JSON body with content blocks means the route is live.
curl https://router.apitoken.sale/v1/messages \
-H "x-api-key: $APITOKEN_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"kimi/k3-256k","max_tokens":256,"messages":[{"role":"user","content":"Reply with exactly: connected"}]}'The response is a standard Anthropic Messages object, and its terminal usage block follows the Anthropic shape — input and output token counts plus the cache legs — so existing usage parsers and cost trackers keep working unchanged.
See also: How to buy a Kimi API key
The official Anthropic SDK needs one extra argument
Because the wire protocol is Anthropic Messages, the official Anthropic Python SDK works unmodified. Two constructor arguments switch it over: api_key reads your key from the environment, and base_url points the client at the router. Keep the key in a server-side environment variable — never in client-side code or a committed file.
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["APITOKEN_API_KEY"],
base_url="https://router.apitoken.sale",
)
message = client.messages.create(
model="kimi/kimi-for-coding",
max_tokens=512,
messages=[{"role": "user", "content": "Reply with exactly: connected"}],
)
print(message.content[0].text)Pass the bare router root, not a path: the SDK appends /v1/messages itself, so a base_url ending in /v1 produces requests to /v1/v1/messages and a 404. The TypeScript SDK takes the same root as baseURL and sends the x-api-key and anthropic-version headers for you.
System prompts, multi-turn histories and tool-use request bodies all serialize exactly as they do against api.anthropic.com — only the model ID and the per-token price differ.
Model IDs are subscription aliases with published rates
The router addresses Kimi through namespaced subscription aliases, and GET https://router.apitoken.sale/v1/models is the authoritative list for your key — availability can depend on provider capacity and account policy, so read the catalog instead of hard-coding a name from external docs.
curl https://router.apitoken.sale/v1/models \ -H "Authorization: Bearer $APITOKEN_API_KEY"
| Public alias | Context | Official hit / miss / output | You pay after 50% off |
|---|---|---|---|
| kimi/kimi-for-coding | 256K | $0.19 / $0.95 / $4 | $0.095 / $0.475 / $2 |
| kimi/kimi-for-coding-highspeed | 256K | $0.38 / $1.90 / $8 | $0.19 / $0.95 / $4 |
| kimi/k3-256k | 256K | $0.30 / $3 / $15 | $0.15 / $1.50 / $7.50 |
| kimi/k3 · kimi/k3[1m] | 1M | $0.30 / $3 / $15 | $0.15 / $1.50 / $7.50 |
Figures are per 1M tokens. Kimi splits input into cache-hit and cache-miss legs because its caching is automatic; the highspeed alias costs exactly double the base Kimi for Coding token rates, so reserve it for work where latency genuinely matters.
Do not substitute an official Open Platform ID such as kimi-k2.7-code. The public router accepts the subscription aliases shown by GET /v1/models, and an official tariff name returns a model error even though it looks correct.
The same aliases work on the OpenAI-compatible lane
If your stack is built on the OpenAI SDK — or on a framework that hard-codes the Chat Completions shape — you do not need the Anthropic surface at all. The router's universal /v1 lane serves the identical kimi/* aliases through Chat Completions:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["APITOKEN_API_KEY"],
base_url="https://router.apitoken.sale/v1",
)
completion = client.chat.completions.create(
model="kimi/kimi-for-coding",
messages=[{"role": "user", "content": "Reply with exactly: connected"}],
)
print(completion.choices[0].message.content)Match the auth header to the lane: the OpenAI-compatible /v1 surface wants Authorization: Bearer sk-pool-…, and sending x-api-key there returns a 401. The Anthropic Messages surface is the mirror image — x-api-key required, Bearer rejected.
Usage accounting, streaming and billing behavior
- Terminal usage arrives in the Anthropic response shape on every call, so per-request token and cost tracking needs no changes.
- Kimi publishes no separate cache-write price: a newly cached token bills as a cache miss, and repeat context comes back on the cheaper cache-hit leg automatically.
- Reasoning tokens are a subset of output and bill at the output rate — they are not metered again as a separate token class.
- The route accepts stream: true, but upstream and public chunk incrementality remain under live validation. Use non-streaming mode when chunk timing matters to your UX.
- A 402 response means the prepaid balance needs a top-up; settled usage per request is visible in the dashboard, and a lifetime key spending limit caps what any single key can burn.
Every call is metered at the official Kimi token rates above, then your flat 50% discount is subtracted before the draw hits the balance — the same billing rule that applies to Claude, GPT and Gemini usage on this key.
Cache legs, alias mapping and spend controls in the pricing guide →
One key plugs into every coding agent
The endpoint and key you just verified are the same credentials the coding-agent setups use, so there is nothing new to buy or provision when you move from scripts to an agent loop. Each agent has its own configuration contract, covered in a dedicated guide:
- Claude Code speaks Anthropic Messages natively — point it at the router and pin every internal model tier to one Kimi alias.
- Kimi Code takes an OpenAI-compatible provider block in config.toml and addresses models as kimi/k3, openai/* or google/* on the same entry.
- OpenCode consumes the router's key-scoped live catalog through the apiToken.sale plugin, so retired aliases never linger in local config.
Run Kimi K3 and Kimi for Coding in Claude Code →
Frequently asked questions
Can I use the Anthropic SDK for Kimi?
Yes. Point its base_url at https://router.apitoken.sale and choose a kimi/* model ID from the key-scoped catalog — imports, streaming code and error handling stay the same.
What model ID should I start with?
Use kimi/kimi-for-coding as the economical coding default, or kimi/k3-256k when you need K3 reasoning without the full 1M window. Confirm availability for your key with GET /v1/models first.
Can I set stream: true on the Kimi route?
The route accepts it, but upstream and public chunk incrementality are still being live-verified. Use non-stream mode when chunk timing matters.
Why does the router reject official Kimi model names?
The public router accepts the subscription aliases shown by GET /v1/models, not Open Platform IDs such as kimi-k2.7-code. An official tariff name returns a model error even though it looks correct.
How much does Kimi for Coding cost per million tokens?
Official replacement rates are $0.19 per 1M cache-hit tokens, $0.95 per 1M cache-miss tokens and $4 per 1M output tokens; apiToken.sale charges half. The highspeed alias is exactly double the base rates.
Does Kimi usage share a balance with Claude, GPT and Gemini?
Yes. One sk-pool key and one prepaid balance cover all four providers; top up any whole-dollar amount by card or crypto and every provider draws from the same pool.
Use Google or GitHub to create your key and get $5 of platform bonus credit before you top up.