Your first request

Five steps: get a key, put it in your environment, send a request, read the cost, check the balance.

The shortest path from nothing to a model's answer. One thing is needed from the cabinet — a key.

Step 1. Get a key

Create a key in the cabinet, on the "Keys" page (app.teamtoken.store/keys). The details about headers, limits and leaks are on /docs/auth.

Step 2. Put the key in an environment variable

A key spends real money: it does not belong in code, in a config under git or in shell history. The examples below read it from the environment.

export TEAMTOKEN_KEY="sk-…"

Step 3. Send the request

The base URL is https://api.teamtoken.store/v1 and the route is /v1/chat/completions. The model name comes from GET /v1/models or from the priced catalog GET /cabinet/api/public/models; the examples use gpt-5.6-sol.

In an SDK there is nothing to change beyond base_url and the key.

curl https://api.teamtoken.store/v1/chat/completions \
  -H "Authorization: Bearer $TEAMTOKEN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [{ "role": "user", "content": "Hi" }],
    "max_tokens": 200
  }'
from openai import OpenAI
import os

client = OpenAI(base_url="https://api.teamtoken.store/v1", api_key=os.environ["TEAMTOKEN_KEY"])

r = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Hi"}],
    max_tokens=200,
)
print(r.choices[0].message.content)

Step 4. Read the cost in the answer

The answer arrives in OpenAI's shape plus our cost: the x-teamtoken-cost-usd header and the usage.cost_usd field (in cURL -i prints the headers; in the Python SDK the non-standard usage sits in model_extra).

It is a decimal string, not a number: as a number the client language would re-display it by its own rules. Budget arithmetic over it belongs in decimal, not float.

A stream carries no cost in its headers — they leave before it is knowable. Ask for the final usage frame with stream_options and include_usage: without it the gateway does not parse the stream.

{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "model": "gpt-5.6-sol",
  "choices": [
    { "index": 0, "message": { "role": "assistant", "content": "Hi!" }, "finish_reason": "stop" }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 12, "cost_usd": "0.0000465" }
}

Step 5. Check the balance

Behind the same key: GET /v1/balance returns granted, spend, remainder and currency. The spend includes holds for generations still running, so queueing a job lowers the remainder at once.

curl https://api.teamtoken.store/v1/balance \
  -H "Authorization: Bearer $TEAMTOKEN_KEY"

Where to go next: media and the catalog

Images and video are shaped as jobs — how exactly is on /docs/intro and on the route pages.

Which models exist and what they cost — GET /cabinet/api/public/models and /cabinet/api/public/media-models; no key needed, and they are the only source of prices.

The full reference is /docs, the same contract machine-readable is /openapi.public.ru.json. Configs for agents and IDEs are there too, under "Connect your tool".