Sign inSign up
DocsOpenAI Responses API

OpenAI Responses API

Call Tokener CA with the OpenAI SDK over the OpenAI Responses protocol — client setup, streaming events, function tools, JSON output, reasoning, the stateless rules, usage, and errors.

Updated:

When to use this

Use this guide when you have code written against the OpenAI Responses API (responses.create) and it carries its own conversation state. Tokener CA exposes the OpenAI Responses protocol at https://a.tokener.ca/v1/responses. The same key, wallet, prices, and Usage page back this protocol and the other two.

Base URL and key

Point the OpenAI SDK at:

Text
https://a.tokener.ca/v1

Authenticate with Authorization: Bearer <your_api_key>. The same OpenAI client can call Chat Completions and Responses.

First request

import OpenAI from "openai"; const client = new OpenAI({  apiKey: process.env.TOKENER_API_KEY,  baseURL: "https://a.tokener.ca/v1",}); const response = await client.responses.create({  model: "glm-5.3:flash",  input: "Introduce Tokener CA in one sentence.",  max_output_tokens: 128,});console.log(response.output_text);

The raw wire equivalent:

Bash
curl https://a.tokener.ca/v1/responses \  -H "Authorization: Bearer $TOKENER_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "glm-5.3:flash",    "input": "Introduce Tokener CA in one sentence.",    "max_output_tokens": 128  }'

The stateless rules

This protocol is stateless here. Send the whole conversation in input on every call. These fields are rejected with a 400: previous_response_id, conversation, store: true, background: true. Carry the conversation yourself:

Python
response = client.responses.create(    model="glm-5.3:flash",    input=[        {"role": "user", "content": "My name is Sam."},        {"role": "assistant", "content": "Nice to meet you, Sam."},        {"role": "user", "content": "What is my name?"},    ],    max_output_tokens=64,)print(response.output_text)

Streaming

Set stream: true. Responses streams typed events; the run ends with response.completed (or response.incomplete when the output limit cuts it):

const stream = await client.responses.create({  model: "glm-5.3:flash",  input: "Give me a minimal HTTP client example.",  max_output_tokens: 256,  stream: true,});for await (const event of stream) {  if (event.type === "response.output_text.delta") process.stdout.write(event.delta);}

A failure after the stream started arrives as a response.failed (or error) event inside the 200 response.

Function tools

Function tools are supported (hosted tools such as web search or file search are not offered). Round 1 returns a function_call item; send its result back as a function_call_output item in the next input:

Python
tools = [{    "type": "function",    "name": "get_weather",    "description": "Get the weather for a city.",    "parameters": {        "type": "object",        "properties": {"city": {"type": "string"}},        "required": ["city"],    },}] first = client.responses.create(    model="glm-5.3:flash",    input="What is the weather in Paris? Use the tool.",    tools=tools,    max_output_tokens=256,) final = client.responses.create(    model="glm-5.3:flash",    input=[        {"role": "user", "content": "What is the weather in Paris? Use the tool."},        {"type": "function_call", "call_id": "<call_id>", "name": "get_weather", "arguments": "{\"city\":\"Paris\"}"},        {"type": "function_call_output", "call_id": "<call_id>", "output": "21C, sunny"},    ],    tools=tools,    max_output_tokens=256,)print(final.output_text)

JSON output

Ask for JSON with text.format:

JSON
{ "text": { "format": { "type": "json_object" } } }

A json_schema format with a name, strict, and schema is also accepted. Whether a given model honours a JSON mode varies by model.

Reasoning

Set reasoning with reasoning.effort:

JSON
{ "reasoning": { "effort": "medium" } }

"none" turns thinking off. The Tokener CA Playground Reasoning selector shows a model's available levels.

Usage and errors

Each response carries usage.input_tokens, usage.output_tokens, and usage.input_tokens_details.cached_tokens. The input_tokens count is the total input, and the cached count is part of it — see How the numbers are counted and billed. The Usage page records the protocol of every request; cached input is billed at the model's cache-read rate where it has one. Errors use the OpenAI error envelope; a rejected stateless field returns 400 with the offending param (for example store). The API reference lists every endpoint, accepted header, required field and error code across the three protocols.