TokenX Gateway documentation

An OpenAI-compatible API in front of Claude, GPT, Gemini and open models. If your code talks to the OpenAI Chat Completions API, it already talks to TokenX.

Base URL: https://api.xtoken.com.au/v1 · Keys start with xtk_ · All requests are HTTPS and JSON.

Quick start

  1. Request a key at [email protected]. You receive an xtk_ key; paste it into the usage dashboard to see spend, limits and try requests.
  2. Set the base URL and key in your existing OpenAI client.
  3. Pick a model id from the model list.
curl https://api.xtoken.com.au/v1/chat/completions \
  -H "Authorization: Bearer $XTOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4.5",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}],
    "max_tokens": 64
  }'

Authentication

Send your key as a bearer token: Authorization: Bearer xtk_.... Keys are scoped to an organisation, can be rotated or revoked at any time from the dashboard, and carry their own rate limit and monthly spend cap. Treat keys as secrets: load them from environment variables or a secret manager, never commit them to source control or ship them in client-side code.

Endpoints

MethodPathDescription
POST/v1/chat/completionsChat completion. OpenAI request and response schema; supports stream: true.
GET/v1/modelsModels available to your key, in OpenAI list format.
GET/v1/usageToken and cost totals for the current billing period, per model and per key.
GET/healthGateway liveness. Returns {"ok": true}.

Models & routing

The model field accepts a TokenX model id (recommended) or a raw upstream id. TokenX ids are stable aliases such as claude-sonnet-4.6; when a provider releases a dated revision we update the alias and announce it in the changelog, so your code keeps working. Raw ids such as us.anthropic.claude-sonnet-4-6 pin an exact upstream version.

Each request is fulfilled by exactly one provider: Anthropic, Meta, DeepSeek, Qwen and Amazon models via AWS Bedrock; OpenAI models via Azure AI Foundry; Gemini via Google Vertex AI. Responses include the upstream model id in the model field so you always know what served the request.

Current list: /models. Programmatic list: GET /v1/models.

Streaming

Set "stream": true to receive server-sent events in the OpenAI chat.completion.chunk format, terminated by data: [DONE]. Streaming works identically across providers; token usage is sent in the final chunk.

stream = client.chat.completions.create(
    model="gemini-3-flash", stream=True,
    messages=[{"role": "user", "content": "Write a haiku about Sydney Harbour."}],
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Parameters

ParameterSupportNotes
messagesallsystem, user, assistant roles. Image content parts supported on vision-capable models.
max_tokensallMapped to the provider's output limit. Also accepts max_completion_tokens.
temperature, top_pallPassed through. Some reasoning models ignore temperature.
stopallUp to 4 sequences.
tools, tool_choiceClaude, GPT, Gemini, NovaOpenAI function-calling schema, translated per provider. Returned as tool_calls.
response_formatGPT, Geminijson_object and json_schema.
userallOpaque end-user id, stored with usage records for your reporting. Do not send personal data.

Errors

Errors use the OpenAI error envelope: {"error": {"message": "...", "type": "...", "code": "..."}}.

HTTPMeaningWhat to do
400Invalid requestCheck the message against the schema above; the body says which field.
401Missing or invalid keyCheck the Authorization header. Revoked keys return 401.
403Model not enabled for this keyAsk us to enable it, or pick another model from GET /v1/models.
404Unknown model idSee /models.
429Rate limit or spend cap reachedBack off using Retry-After. Caps are adjustable; contact us.
502 / 503Upstream provider error or overloadRetry with exponential backoff; consider a fallback model.

Rate limits

Limits are per key, in tokens per minute (TPM) and requests per minute (RPM), and are returned on every response in x-ratelimit-limit-tokens, x-ratelimit-remaining-tokens, x-ratelimit-limit-requests and x-ratelimit-remaining-requests. Starter keys begin at 200K TPM / 200 RPM; higher limits are set with you based on your workload.

Data residency

By default requests are routed to the provider region with the best availability for the chosen model (United States for most frontier models). Keys can be pinned to the au tier, which restricts inference to Sydney (AWS ap-southeast-2 and Azure australiaeast) and only exposes models available there. Request content is processed in memory and is not stored by TokenX; metadata (timestamps, token counts, model, status, your user field) is retained for billing and support for 90 days. See Security.

Usage & billing

Billing is per token at the rates on the pricing page, in USD, invoiced monthly in arrears for approved accounts or drawn from prepaid credit. GET /v1/usage and the dashboard show spend by model and key. Every response carries usage.prompt_tokens, usage.completion_tokens and usage.total_tokens as reported by the provider.

SDK examples

Python

from openai import OpenAI
client = OpenAI(base_url="https://api.xtoken.com.au/v1", api_key=os.environ["XTOKEN_API_KEY"])
r = client.chat.completions.create(model="gpt-5-mini", messages=[{"role": "user", "content": "Hi"}])

Node.js

import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.xtoken.com.au/v1", apiKey: process.env.XTOKEN_API_KEY });
const r = await client.chat.completions.create({ model: "claude-opus-4.6", messages: [{ role: "user", content: "Hi" }] });

LangChain

from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="deepseek-v3.2", base_url="https://api.xtoken.com.au/v1", api_key=os.environ["XTOKEN_API_KEY"])

Anything that accepts an OpenAI base URL — Vercel AI SDK, LiteLLM, Continue, Cursor, Open WebUI — works the same way.