Developer docs

Quickstart for routing AI requests through Tokenok.

Use OpenAI-compatible and Anthropic-compatible endpoints while Tokenok handles customer identity, provider policy, usage metering, billing records, and fallback routing.

1

Create an API key

Sign in to the Customer Portal, create or rotate an API key, and store the raw key securely. It is shown only once.

2

Call the gateway

curl https://api.tokenok.net/v1/chat/completions \
  -H "Authorization: Bearer $TOKENOK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-4.1-mini","messages":[{"role":"user","content":"Hello"}]}'
3

Review usage and billing

Use `/console`, `/me/request-logs`, `/me/billing/statement`, invoice PDFs, and CSV exports to reconcile customer usage.

API docs

Interactive FastAPI documentation is available at /api/docs.

Payment webhooks

Payment providers must POST signed paid events to `/webhooks/payments/{payment_provider}` before balance credit is applied.

SDK compatibility

Use the OpenAI SDK with Tokenok credentials.

from openai import OpenAI

client = OpenAI(
    api_key="TOKENOK_API_KEY",
    base_url="https://api.tokenok.net/v1",
)

response = client.chat.completions.create(
    model="tokenok-fast",
    messages=[{"role": "user", "content": "Hello from Tokenok"}],
)

Provider-specific models and aliases are controlled in the Tokenok admin console, so application code can stay stable while routing changes.

Migration checklist

Move first traffic in four controlled steps.

01

Replace the Base URL

Point your OpenAI-compatible client at `https://api.tokenok.net/v1` and keep the same chat completions shape.

02

Issue a Tokenok key

Create a customer API key with provider and model policy, then store the raw key in your application secret manager.

03

Use a routing alias

Start with `model=\"tokenok-fast\"`, then test premium, coding, or provider-specific routes as volume grows.

04

Observe usage

Check request logs, balances, provider health, failed requests, and billing statements before moving production traffic.