Quickstart

TokenCannon is OpenAI-compatible: any OpenAI SDK works unchanged once you point it at our base URL, https://main-api.dev.tokencannon.io/v1.

Get an API key

Create an API key, add a credit pack, and copy the key from the console. Keys look like tc_live_… and are shown once; we store only a hash.

shell
export TOKENCANNON_API_KEY="tc_live_..."

Make a request

Pick a model id from the catalog and call /v1/chat/completions. Streaming, tool calls, and usage all work as they do with OpenAI.

curl

shell
curl https://main-api.dev.tokencannon.io/v1/chat/completions \
  -H "Authorization: Bearer $TOKENCANNON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tokencannon/qwen3-0.6b",
    "messages": [{"role": "user", "content": "Say hello in five words."}]
  }'

Python

main.py
from openai import OpenAI

client = OpenAI(
    base_url="https://main-api.dev.tokencannon.io/v1",
    api_key=os.environ["TOKENCANNON_API_KEY"],
)

response = client.chat.completions.create(
    model="tokencannon/qwen3-0.6b",
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(response.choices[0].message.content)
print(response.usage)

TypeScript

main.ts
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://main-api.dev.tokencannon.io/v1",
  apiKey: process.env.TOKENCANNON_API_KEY,
});

const response = await client.chat.completions.create({
  model: "tokencannon/qwen3-0.6b",
  messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(response.choices[0]?.message.content);
console.log(response.usage);

Next steps

  • Models: how to read the published configuration.
  • API reference: authentication, endpoints, and errors.