token labs

Experiments & resources

API GUIDE

From a prompt to your app.

Use your Token Labs provider key with an OpenAI-compatible client. Discover available models before sending a request.

1. Find a model

The model list reflects currently available backends. Copy an ID from the response into the examples below.

export TOKENLABS_API_KEY='your-provider-key'
curl https://api.tokenlabs.run/openrouter/v1/models \
  -H "Authorization: Bearer $TOKENLABS_API_KEY"

2. Send a message

Replace MODEL_ID with the ID returned above.

curl
curl https://api.tokenlabs.run/openrouter/v1/chat/completions \
  -H "Authorization: Bearer $TOKENLABS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"MODEL_ID","messages":[{"role":"user","content":"Hello!"}],"max_tokens":1024,"chat_template_kwargs":{"enable_thinking":false}}'
Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokenlabs.run/openrouter/v1",
    api_key=os.environ["TOKENLABS_API_KEY"],
)
response = client.chat.completions.create(
    model="MODEL_ID",
    messages=[{"role": "user", "content": "Hello!"}],
    max_tokens=1024,
    extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(response.choices[0].message.content)

A few useful details

Add stream: true to receive a response as it is generated. Thinking is disabled in these examples so the output budget goes toward the answer. Keep your key private and use a server-side proxy when building a public app.

HTTP 401 means the key was not accepted. HTTP 429 means the service is at capacity; retry after the delay in the response’s Retry-After header.

How inference data is handled →