Who this page is for
Start here if you want to connect an application, script, AI coding tool, or an OpenAI- or Anthropic-compatible client to Tokener CA. After reading this guide, you should be able to create an API key and complete your first model call.
The caller-side flow for Tokener CA is simple:
- Use one unified
baseURL - Use an API key as the Bearer token
- Select a platform model with the request body's
modelfield - Call the protocol that matches your code — Chat Completions, Responses, or Messages
- Review usage, status, failure reasons, and billing records in the console
API entry point
For production, set your OpenAI-compatible client's baseURL to:
https://a.tokener.ca/v1The endpoints are:
https://a.tokener.ca/v1/chat/completionshttps://a.tokener.ca/v1/responseshttps://a.tokener.ca/v1/messageshttps://a.tokener.ca/v1/modelsAll requests carry the key in a header:
Authorization: Bearer <your_api_key>https://a.tokener.ca/v1/messages also accepts the Anthropic-style x-api-key: <your_api_key> header. Do not put the API key in URLs, logs, public frontend code, or configuration files that users can download.
Choose a protocol
The same key, wallet, prices, and usage page back all three protocols. Pick the one that matches the code you already have:
| Protocol | Endpoint | Auth header | Use it when |
|---|---|---|---|
| OpenAI-compatible (Chat Completions) | https://a.tokener.ca/v1/chat/completions | Authorization: Bearer | The default. Widest tool support; every integration guide on this site uses it. |
| OpenAI Responses | https://a.tokener.ca/v1/responses | Authorization: Bearer | You have code written against the OpenAI Responses API (responses.create) and it carries its own conversation state. |
| Anthropic-compatible (Messages) | https://a.tokener.ca/v1/messages | Authorization: Bearer or x-api-key | You have code written against the Anthropic SDK or the Messages wire format. |
OpenAI-compatible (Chat Completions)
The default protocol. Use https://a.tokener.ca/v1/chat/completions for chat, streaming, tool calls, and multimodal input. Every AI-tool integration guide on this site configures this protocol. See "Make your first request" below.
OpenAI Responses
OpenAI Responses over https://a.tokener.ca/v1/responses. This protocol is stateless here: send the whole conversation in input on every call. previous_response_id, conversation, store: true, and background: true are rejected with a 400. Function tools are supported; hosted tools (web search, file search, and similar) are not offered. Full guide: OpenAI Responses API.
Anthropic-compatible (Messages)
The Anthropic Messages wire format over https://a.tokener.ca/v1/messages. max_tokens is required. There is no JSON-output mode on this protocol; reasoning is switched with thinking (enabled with a budget_tokens below max_tokens, or disabled); tool use works with tool_use / tool_result blocks; errors use the Anthropic error envelope and carry a request-id header. POST https://a.tokener.ca/v1/messages/count_tokens returns a request's input-token count and is free, on accounts that allow all model suppliers (see Who processes my requests?). For the Anthropic SDKs, set the base URL to https://a.tokener.ca (no /v1 — the SDK appends it). Full guide: Anthropic SDK.
Same account, same bill
One API key works on all three protocols. They share the same wallet, the same model prices, and the same Usage page, which shows the protocol of every request. Requests are paid from your balance or, if you have one, from a monthly Agent plan up to its 5-hour and weekly limits — see the Agent plan guide. Which features a model supports (images, tools, reasoning) varies by model as well as by protocol — try a combination in the Tokener CA Playground.
Step 1: Create an API key
Log in to the Tokener CA console, open the API keys page, and create a key. Once the key is created, the page shows it in full. Keys start with tok-.
We recommend splitting keys by application or environment, for example:
| Scenario | Recommendation |
|---|---|
| Local development | Create a separate development key so it is easy to debug and delete at any time |
| Production service | Use a production key that is deployed only on the server side |
| AI coding tools | Create a separate key for each tool or team to make abnormal requests easier to troubleshoot |
| Temporary testing | Delete the key after testing to avoid leaving long-lived credentials behind |
Step 2: Choose a model
View currently available models on the Models page or in the usage examples in the console.
You can also read the model list through the API:
https://a.tokener.ca/v1/modelsContext length, pricing, tool-calling support, and multimodal capabilities may vary by model. A model card may also show a precision tag where its supplier states it — BF16 means unquantized weights, FP8 an 8-bit release; precision is per model and the tag describes the model's default route. Before connecting a production application, we recommend confirming the target model's response structure and failure semantics in the console or with a test script.
Step 3: Make your first request
The following is a minimal non-streaming request. Set TOKENER_API_KEY to your API key, and change model to the model you want to use.
For an even simpler test path, you can try it directly in the Tokener CA Playground.
From the Playground
In the Playground, Get Code shows the exact request the Playground would send, for the selected protocol. You can create a key right there and optionally insert it into the sample — the key is shown once and can be deleted from API keys at any time.
curl -X POST "https://a.tokener.ca/v1/chat/completions" \ -H "Authorization: Bearer $TOKENER_API_KEY" \ -H "Content-Type: application/json" \ --data-raw '{ "model": "glm-5.3:flash", "messages": [ { "role": "user", "content": "Hello, introduce Tokener CA in one sentence." } ], "max_tokens": 128, "stream": false }'If the response contains choices[0].message.content, your key, endpoint, and model are working.
Beyond text: images, audio, and files
The Tokener CA Playground accepts more than plain text. You can attach images, audio, PDFs, videos, and Office documents (Word, Excel, and PowerPoint). Which inputs a given model accepts natively is shown per model on the Models page under its input modalities.
When a model natively supports an input type, the Playground sends the file directly (for example an image as an image_url part). When it does not, the Playground converts the file in your browser first, then sends the result as ordinary text or image parts, so the model still receives usable content:
- PDFs and Office documents become extracted text, and page or slide images where that helps.
- Videos become a set of sampled key-frame images.
- Audio is transcribed to text locally in your browser.
All conversion happens client-side before the request is sent; the Playground does not store your files. To see exactly what would be sent for your current attachment, open Get Code or the Request JSON tab — attachments are shown there as placeholders, never as raw bytes.
How do I send an image through the API?
Send the image inline, as a base64 data URL: data:image/<type>;base64,<data> (the Playground accepts PNG, JPEG and WebP images). Tokener does not fetch remote images — an image part that points at an http:// or https:// URL is rejected with 400 invalid_request_error before the request is sent to a model, and nothing is charged. Download the image yourself and encode it, then pick a model whose input modalities on the Models page include images:
import base64import osimport urllib.request from openai import OpenAI client = OpenAI( api_key=os.environ["TOKENER_API_KEY"], base_url="https://a.tokener.ca/v1",) # Download the image, then send its bytes inline as a data URL.with urllib.request.urlopen("https://example.com/photo.jpg") as response: data_url = "data:image/jpeg;base64," + base64.b64encode(response.read()).decode("ascii") completion = client.chat.completions.create( model="glm-5.3:flash", # a model that accepts image input messages=[ { "role": "user", "content": [ {"type": "text", "text": "Describe this image in one sentence."}, {"type": "image_url", "image_url": {"url": data_url}}, ], } ], max_tokens=128,)print(completion.choices[0].message.content)The image-part shape for each protocol is in the API reference.
Step 4: Enable streaming output
For interactive scenarios such as chat, agents, and AI coding tools, streaming output is recommended. Use stream: true for streaming requests, and include stream_options.include_usage: true so the final frame can return real usage.
curl -N -X POST "https://a.tokener.ca/v1/chat/completions" \ -H "Authorization: Bearer $TOKENER_API_KEY" \ -H "Content-Type: application/json" \ --data-raw '{ "model": "glm-5.3:flash", "messages": [ { "role": "user", "content": "Give me a minimal TypeScript HTTP client example." } ], "max_tokens": 512, "stream": true, "stream_options": { "include_usage": true } }'Streaming shapes differ by protocol:
- Chat Completions:
data:chunks, a final usage chunk, ending indata: [DONE]. - Responses: typed events ending in
response.completed(orresponse.incompletewhen the output limit cuts it). - Messages:
message_start…message_delta…message_stop.
A failure that happens after a stream has started arrives as an event inside a 200 response, so streaming clients should handle both incremental content and mid-stream error events.
Reasoning controls
Some models can think before answering. On Chat Completions you control this per request with the same fields the Tokener CA Playground sends — the platform forwards them to the model unchanged. A model that does not support a given control simply ignores it, and each model's supported modes appear in the Reasoning selector of the Playground when that model is selected.
Turn thinking off (answer directly, fewer prompt tokens):
{ "reasoning_effort": "none", "think": false, "chat_template_kwargs": { "enable_thinking": false } }"reasoning_effort": "none" is the recommended switch; the other two fields keep older runtimes and other models in step.
Turn thinking on (models with a plain on/off switch):
{ "chat_template_kwargs": { "enable_thinking": true } }Set a reasoning effort (models that accept levels — the Playground Reasoning selector shows which levels a model offers):
{ "reasoning_effort": "xhigh" }Reasoning levels are per model: the model's page on /models lists the levels it offers and marks its default. A request that carries no reasoning field gets that default. On a model that cannot turn reasoning off, none selects its lowest effort instead.
On the Responses protocol, reasoning is set with reasoning.effort; on Messages, with thinking. See the OpenAI Responses API and Anthropic SDK guides.
Use the OpenAI SDK
Any OpenAI SDK or compatible client that supports a custom baseURL can connect directly to Tokener CA. The same client can call Chat Completions and Responses.
import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.TOKENER_API_KEY, baseURL: "https://a.tokener.ca/v1",}); // Chat Completionsconst completion = await client.chat.completions.create({ model: "glm-5.3:flash", messages: [ { role: "user", content: "Explain an OpenAI-compatible API in one sentence." }, ], max_tokens: 128,});console.log(completion.choices[0]?.message?.content); // OpenAI Responses (stateless: send the whole conversation in `input`)const response = await client.responses.create({ model: "glm-5.3:flash", input: "Explain the Responses API in one sentence.", max_output_tokens: 128,});console.log(response.output_text);For the Anthropic SDKs (https://a.tokener.ca as the base URL), see the Anthropic SDK guide.
Connect AI coding tools
AI coding tools usually need only three pieces of information:
| Configuration item | Value |
|---|---|
| API Key | Your API key, for example tok-... |
| Base URL | https://a.tokener.ca/v1 |
| Chat Completions URL | https://a.tokener.ca/v1/chat/completions |
| Model | Platform model name, for example glm-5.3:flash |
The listed tools use the OpenAI-compatible (Chat Completions) protocol. Different tools use slightly different names for endpoint fields — some ask for a baseURL, others for the full chat completions address. Check the tool's field descriptions before configuring it:
- If the field is named
baseURL,Base URL, orOpenAI API Base, enterhttps://a.tokener.ca/v1 - If the field is named
endpoint,API Endpoint, orAPI URL, and the example includes/chat/completions, enterhttps://a.tokener.ca/v1/chat/completions
For common tool integrations, see:
- WorkBuddy integration
- OpenCode integration
- Cline integration
- Dify integration
- LiteLLM integration
- Vercel AI SDK integration
For the Claude Code CLI, which uses the Anthropic-compatible (Messages) protocol instead, see the Claude Code guide.
Request parameter recommendations
| Parameter | Recommendation |
|---|---|
model | Use a model ID from the platform Models page or the /v1/models response |
messages | Follow the OpenAI-compatible message structure, and use the tool role for tool results |
stream | Set to true for chat, agent, and long-output scenarios |
stream_options.include_usage | Set to true for streaming requests so usage and billing are easier to verify |
max_tokens | Set an explicit output limit to avoid uncontrolled usage on long tasks (required on the Messages protocol) |
temperature | For production tasks, start with a lower value and tune it for your business case |
tools | Use the OpenAI-compatible tools structure when function calling is needed |
Who processes my requests?
By default, your requests are processed only by model suppliers that commit to not storing request content and not using it for training. In Account settings → Data handling you can turn on Also allow suppliers without that commitment:
- It can improve availability when a supplier is busy or temporarily unavailable.
- While it is on, you are billed a percentage below the current price on every model — the current discount is shown on Pricing and on the Data handling page.
- Those suppliers may process requests in other countries, under the laws of those countries.
- Token counting on the Anthropic-compatible (Messages) protocol is available only while it is on.
You can turn it off at any time; the change applies to your next request. For how Tokener handles your data, see the Privacy policy.
Review your usage
After a request completes, open the Usage page in your account. There you can review the request time, model, protocol, status, token usage, failure reason, and billing information. Cached input is billed at the model's cache-read rate where it has one; on the Messages protocol, when a response's input accounting can be read in more than one way, Tokener bills the lower reading. For exactly how the usage numbers are counted and turned into a charge, see How the numbers are counted and billed.
If you are debugging a third-party tool, first use curl or the Tokener CA Playground to verify the same key and model, then migrate the same parameters into the tool configuration. This helps you quickly tell whether the issue is on the platform call path or in the tool-side configuration.
Common errors
| Symptom | Check first |
|---|---|
401 or authentication failure | Whether the API key was copied completely, and whether the request uses the Authorization: Bearer (or x-api-key) header |
402 or insufficient balance | Whether the account has enough balance |
404 or model not found | Whether model comes from the current platform model list |
400 on Responses | Whether the request sends previous_response_id, conversation, store: true, or background: true — those are rejected; carry the conversation yourself in input |
400 on Messages | Whether max_tokens is present (it is required); Messages errors use the Anthropic error envelope |
429 or rate limiting | Whether concurrency is too high, and whether you need to lower concurrency or split requests across keys |
5xx or node unavailable | Retry later, and check the failure reason on the Usage page |
| Tool keeps waiting | Whether the streaming client correctly handles the protocol's end-of-stream marker and error events |
For the full list of endpoints, accepted authentication headers, required request fields, streaming formats, usage fields and error codes across all three protocols, see the API reference.
Minimum onboarding checklist
- Log in to the console and create an API key
- Choose a model ID from the Models page or
/v1/models - Pick the protocol that matches your code (Chat Completions, Responses, or Messages)
- Set your client's
baseURL—https://a.tokener.ca/v1for the OpenAI protocols,https://a.tokener.cafor the Anthropic SDKs - Carry the API key as a Bearer token (or
x-api-keyfor Messages) - Verify the basic call with a non-streaming
curlrequest first - Then enable streaming output and tool calls
- Check status, usage, protocol, and failure reasons on the Usage page
