Token Wallet API
An OpenAI-style Chat Completions endpoint in front of every model we stock. One key, one wallet, every model. Calls draw down the matching token pack you own — buy packs on /packs.
Base URL
https://token-wallet.ai/api/v1Every endpoint below is relative to this base.
Authentication
Create a key on the API Keys page. Keys are shown once at creation — store yours in a secret manager. Send it as a bearer token in the Authorization header.
curl https://token-wallet.ai/api/v1/chat/completions \
-H "Authorization: Bearer tw_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4-flash",
"messages": [{ "role": "user", "content": "Hello" }]
}'Chat completions
POST /chat/completions is fully OpenAI-compatible: just model and messages. Calls draw down your subscription quota; model IDs come from GET /models.
{
"model": "deepseek/deepseek-v4-flash",
"messages": [
{ "role": "system", "content": "You are concise." },
{ "role": "user", "content": "Summarise Singapore's AI policy in 3 bullets." }
],
"temperature": 0.5,
"max_tokens": 512,
"stream": false
}The response is a standard OpenAI chat.completion object:
{
"id": "chatcmpl-…",
"object": "chat.completion",
"created": 1783200000,
"model": "deepseek/deepseek-v4-flash",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "…" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 24, "completion_tokens": 86, "total_tokens": 110 }
}Set "stream": true for token-by-token SSE output — standard chat.completion.chunk frames ending with data: [DONE]; the final frame carries usage.
List models
GET /models returns the active models and their per-1M token prices.
curl https://token-wallet.ai/api/v1/models -H "Authorization: Bearer tw_xxxxxxxxxxxx"{
"object": "list",
"data": [
{
"id": "deepseek/deepseek-v4-flash",
"object": "model",
"owned_by": "ppio",
"input_price_per_1m_tokens": 0.19,
"output_price_per_1m_tokens": 0.37
}
]
}Code examples
Python (official OpenAI SDK):
from openai import OpenAI
client = OpenAI(base_url="https://token-wallet.ai/api/v1", api_key="tw_xxxxxxxxxxxx")
r = client.chat.completions.create(
model="deepseek/deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)Node (official OpenAI SDK):
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://token-wallet.ai/api/v1",
apiKey: "tw_xxxxxxxxxxxx",
});
const r = await client.chat.completions.create({
model: "deepseek/deepseek-v4-flash",
messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);GUI clients (Cherry Studio, LobeChat, …): add an “OpenAI-compatible” provider with the base URL above and your tw_ key.
Errors
Errors return { "error": { "message", "type" } } with the matching HTTP status.
- 400Invalid input — model or provider unknown, or schema mismatch.
- 401Missing or invalid API key.
- 402No active pack for this provider/model, or the pack ran out mid-call. Buy a pack at /packs.
- 403Account suspended, or this model isn't allowed for this key.
- 429Rate limit exceeded. Slow down and retry shortly.
- 502Upstream provider error. The call was not charged.
Rate limits
Default: a burst of 10 requests, refilling at ~0.5 requests/second per key. Need more? Get in touch.
Security
- Keys are hashed before storage — we never see the plaintext after creation.
- Pack deductions run inside DB transactions; failed provider calls are never charged.
- Upstream provider keys live only on the server. Never expose them to the browser.
- Revoke a key from the API Keys page the moment you suspect it has leaked.