Docs
TokenFlow API documentation
TokenFlow exposes one API that is compatible with both the OpenAI and the Anthropic formats. Use it from the SDKs, from coding tools such as OpenCode, Claude Code and Hermes, or straight over HTTP.
- Base URL
https://api.tokenflow.id/v1 - Authentication
Authorization: Bearer sk-tf-… - FormatsOpenAI & Anthropic compatible
-
Getting started
- Choose a package on the home page, verify your Telegram, then pay with QRIS. Your account activates automatically.
- Your API key (
sk-tf-…) is shown once after payment. Save it somewhere safe. - Sign in to the Portal to see your balance and usage, reopen your API key with your PIN, or create a new key.
- The quickest route is Portal → Guide: pick a tool and your OS, copy one command and run it in a terminal.
-
Authentication
Send your API key on every request in the
Authorizationheader:Authorization: Bearer sk-tf-YOUR_API_KEYThe Anthropic-compatible endpoint
/v1/messagesalso accepts thex-api-keyheader. Never put your API key in front-end code or a public repository; if it leaks, create a new key in the Portal. -
Model list
Get the model IDs available to your account. Use the
idvalue asmodelin requests.curl https://api.tokenflow.id/v1/models \ -H "Authorization: Bearer $TOKENFLOW_API_KEY"The list follows provider availability and can change. The catalog on the home page also shows each model's grade and multiplier.
-
Chat Completions (OpenAI-compatible)
curlPOST /v1/chat/completionstakes the OpenAI format.modelandmessagesare required.
Python (openai)curl https://api.tokenflow.id/v1/chat/completions \ -H "Authorization: Bearer $TOKENFLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-5.3", "messages": [{"role": "user", "content": "Hello!"}] }'
Node.js (openai)from openai import OpenAI client = OpenAI(base_url="https://api.tokenflow.id/v1", api_key="sk-tf-YOUR_API_KEY") reply = client.chat.completions.create( model="glm-5.3", messages=[{"role": "user", "content": "Hello!"}], ) print(reply.choices[0].message.content)import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.tokenflow.id/v1", apiKey: process.env.TOKENFLOW_API_KEY }); const reply = await client.chat.completions.create({ model: "glm-5.3", messages: [{ role: "user", content: "Hello!" }], }); console.log(reply.choices[0].message.content); -
Messages (Anthropic-compatible)
curlPOST /v1/messagestakes the Anthropic format.model,messagesandmax_tokensare required.
Python (anthropic)curl https://api.tokenflow.id/v1/messages \ -H "x-api-key: $TOKENFLOW_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-5.3", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}] }'import anthropic client = anthropic.Anthropic(base_url="https://api.tokenflow.id", api_key="sk-tf-YOUR_API_KEY") reply = client.messages.create( model="glm-5.3", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], ) print(reply.content[0].text)The Anthropic SDK and Claude Code add
/v1/messagesthemselves, so their base URL ishttps://api.tokenflow.idwithout/v1. -
Streaming
Add
"stream": trueto the body of either endpoint to receive the response bit by bit as Server-Sent Events, in the same format as OpenAI or Anthropic. Token usage is still counted once the stream finishes.curl -N https://api.tokenflow.id/v1/chat/completions \ -H "Authorization: Bearer $TOKENFLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "glm-5.3", "stream": true, "messages": [{"role": "user", "content": "Hello!"}]}' -
Coding tools
The Portal Guide builds a ready-made command for OpenCode, Claude Code and Hermes on Linux, macOS and Windows, and gives 9Router setup steps. To configure a tool by hand:
Claude Code, by hand (Linux/macOS)Tool Format Base URL OpenCode, Hermes, 9Router, other OpenAI-compatible clients OpenAI https://api.tokenflow.id/v1Claude Code, Anthropic SDK Anthropic https://api.tokenflow.idexport ANTHROPIC_BASE_URL="https://api.tokenflow.id" export ANTHROPIC_AUTH_TOKEN="sk-tf-YOUR_API_KEY" export ANTHROPIC_MODEL="glm-5.3" export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3" claudeSupport for non-Claude models in Claude Code depends on the gateway and is not guaranteed by Anthropic.
-
Quota & multipliers
- Every model has a multiplier. Tokens deducted = the request's input and output tokens × the model's multiplier.
- A package is valid for 28 days. A top-up to the same hashtag adds quota and leftover tokens carry over to the new period.
- See your remaining balance, request count and usage per model in the Portal. Use the Estimator to work out which package fits.
-
Errors & limits
Errors come back as JSON:
{"error": {"code": "…", "message": "…"}}. Errors from the model provider are passed on with the same status and message, with any API key in them hidden as[redacted].Status Code Meaning 401 AUTHENTICATION_ERRORThe API key is missing, wrong or no longer active. 413 BODY_TOO_LARGEThe request body is over 2 MiB. 422 VALIDATION_ERRORmodel,messages,stream(ormax_tokensfor Messages) are missing or invalid.429 RATE_LIMITEDToo many attempts with an invalid API key. Wait for the time in the Retry-Afterheader.502 UPSTREAM_OUTCOME_UNKNOWNThe provider did not answer clearly. The request is not retried automatically, so check before sending it again. 503 GATEWAY_UNAVAILABLEThe service is temporarily unavailable. Try again shortly. Still stuck? Contact us on Telegram at @Moneyvesting00.