Documentation
Quickstart
Tokenly speaks the OpenAI wire format — both chat/completions and the newer responses API. Anything that accepts a custom base URL — SDKs, IDE agents, CLIs — works out of the box.
1 · Base URL and auth
Create a key in the dashboard and send it as a Bearer token. Keys are stored as hashes and shown only once.
Base URL https://www.tokenly.llc/api/v1 Header Authorization: Bearer sk-...
2 · Make a call
curl https://www.tokenly.llc/api/v1/chat/completions \
-H "Authorization: Bearer $TOKENLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [{"role": "user", "content": "Hello, Tokenly"}],
"max_tokens": 512
}'Python
from openai import OpenAI
client = OpenAI(
base_url="https://www.tokenly.llc/api/v1",
api_key="sk-...", # your Tokenly key
)
reply = client.chat.completions.create(
model="claude-sonnet-4-5",
messages=[{"role": "user", "content": "Hello, Tokenly"}],
)
print(reply.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.tokenly.llc/api/v1",
apiKey: "sk-...", // your Tokenly key
});
const reply = await client.chat.completions.create({
model: "deepseek-v3-2",
messages: [{ role: "user", content: "Hello, Tokenly" }],
stream: true, // streaming is supported
});Codex CLI
# ~/.codex/config.toml [model_providers.tokenly] name = "Tokenly" base_url = "https://www.tokenly.llc/api/v1" env_key = "TOKENLY_API_KEY" wire_api = "responses" [profiles.tokenly] model_provider = "tokenly" model = "deepseek-v3-2" # then: # export TOKENLY_API_KEY=sk-... # codex --profile tokenly
3 · Pricing
Every response carries x-tokenly-credits-charged and x-tokenly-credits-remaining headers, plus a tokenly usage block in the JSON body.
| Model | Credits / 1M in | Credits / 1M out |
|---|---|---|
| Claude Sonnet 4.5claude-sonnet-4-5 | 3,600 | 18,000 |
| Claude Haiku 4.5claude-haiku-4-5 | 1,200 | 6,000 |
| DeepSeek V3.2deepseek-v3-2 | 340 | 500 |
| GLM-4.6glm-4-6 | 720 | 2,640 |
| Kimi K2kimi-k2 | 700 | 3,000 |
4 · When credits run out
Calls fail with 402 and a connection-error message pointing at the Earn portal. A request whose estimated cost exceeds your remaining balance fails the same way (code insufficient_credits), so a single call can never overdraw you by more than 25 credits. Complete a survey or watch a sponsored film, and the same key starts working again immediately — nothing to restart. The feed resets daily.
HTTP/1.1 402 Payment Required
{
"error": {
"message": "Connection error: your Tokenly credits are used up. Open the portal to earn more — a survey or two tops you back up: https://www.tokenly.llc/earn",
"type": "insufficient_credits",
"code": "credits_exhausted",
"portal": "https://www.tokenly.llc/earn"
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 401 | missing_api_key / invalid_api_key | No key, or the key is wrong or revoked. |
| 402 | credits_exhausted / insufficient_credits | Balance is empty, or the request costs more than what remains — refill at /earn. |
| 403 | model_not_allowed_for_key | Key is scoped to a different model. |
| 404 | model_not_found | Unknown model id — see /api/v1/models. |
| 400 | invalid_body | Missing `model` or `messages`. |