Documentation

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

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.

  1. Create an API key in your dashboard — you can copy it any time from the API keys page.
  2. Top up your balance with a card, SBP or cryptocurrency — Tokenly is prepaid.
  3. Set the base URL and the key in your SDK and send your first request.
Base URL https://tokenly.plus/api/v1

Keys live on the API keys page; the current model slugs are in the model catalogue.

curl
curl https://tokenly.plus/api/v1/chat/completions \ -H "Authorization: Bearer $TOKENLY_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}] }'
Authentication

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.

HTTP
# works on every endpointAuthorization: Bearer sk-disc-... # native alternative accepted by /api/v1/messagesx-api-key: sk-disc-...

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

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
Balance

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.

curl
curl https://tokenly.plus/api/v1/balance \ -H "Authorization: Bearer $TOKENLY_KEY"
Response
{ "balance": "12.34567890", "currency": "USD"}

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

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.

from openai import OpenAI client = OpenAI( api_key="sk-disc-...", # your Tokenly key base_url="https://tokenly.plus/api/v1", # ← the only change) resp = client.chat.completions.create( model="gpt-5.5", messages=[{"role": "user", "content": "Hello!"}],)
from anthropic import Anthropic client = Anthropic( api_key="sk-disc-...", # your Tokenly key base_url="https://tokenly.plus/api", # ← the only change) msg = client.messages.create( model="claude-opus-4.8", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}],)
import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.TOKENLY_KEY, baseURL: "https://tokenly.plus/api/v1", // ← the only change}); const resp = await client.chat.completions.create({ model: "gemini-3.1-pro", messages: [{ role: "user", content: "Hello!" }],});
curl https://tokenly.plus/api/v1/chat/completions \ -H "Authorization: Bearer $TOKENLY_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}] }'
Streaming

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.

curl -N https://tokenly.plus/api/v1/chat/completions \ -H "Authorization: Bearer $TOKENLY_KEY" \ -H "Content-Type: application/json" \ -d '{ "stream": true, "model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}] }'
stream = client.chat.completions.create( model="gpt-5.5", stream=True, messages=[{"role": "user", "content": "Hello!"}],) for chunk in stream: print(chunk.choices[0].delta.content or "", end="")

Billing is metered from the final stream chunk, so a streamed request costs the same as a non-streamed one.