Developer documentation
Tokenly is a drop-in replacement for the OpenAI and Anthropic APIs. Point your SDK at Tokenly, change the key — and everything else works as before. Below: how to send your first request, how authentication works, ready-to-use code samples and streaming.
Quick start
Three steps to your first request. If you already use the OpenAI or Anthropic SDK, only the base URL and the key change.
- Create an API key in your dashboard — you can copy it any time from the API keys page.
- Top up your balance with a card, SBP or cryptocurrency — Tokenly is prepaid.
- Set the base URL and the key in your SDK and send your first request.
https://tokenly.plus/api/v1
Keys live on the API keys page; the current model slugs are in the model catalogue.
Authentication
Every request is authenticated with an API key passed in the Authorization header as a Bearer token. One key routes to every provider — the provider is chosen by the model in the request body.
You can copy an API key at any time from the API keys page. Keep it secret and revoke any compromised key there.
Error codes
- 401Invalid or disabled key
- 402Insufficient balance
- 404Unknown model
- 503Provider unavailable or server busy
Endpoints
Pick the endpoint that matches your model's provider dialect — the model in the request body decides which upstream provider the request is routed to.
| Endpoint | Dialect | Providers |
|---|---|---|
POST /api/v1/chat/completions |
OpenAI Chat Completions | OpenAI, Gemini, Anthropic |
POST /api/v1/responses |
OpenAI Responses | OpenAI |
POST /api/v1/messages |
Anthropic Messages | Anthropic |
GET /api/v1/balance |
Tokenly | — |
Check balance
Fetch your current prepaid balance programmatically with the same API key you use for requests — handy for dashboards, low-balance alerts or a pre-flight check in CI before a big job.
balance is a decimal string in US dollars at full precision. This endpoint is never funds-gated, so you can poll it even at a zero or negative balance to decide when to top up.
Code examples
The API is fully compatible with the OpenAI and Anthropic SDKs. Pick your stack — the only change is the base URL and the key.
Streaming
Streaming is supported on every endpoint. Add "stream": true to the request body and the response arrives as a Server-Sent Events (SSE) stream — exactly as it does with the provider directly.
Billing is metered from the final stream chunk, so a streamed request costs the same as a non-streamed one.