Tokza developer documentation

One API for text, images, audio and media models

Start with the OpenAI-compatible interface, discover what your account can use, and treat every model’s capability labels as the source of truth for alternate formats.

Observed Public gateway and catalog checked August 14, 2026

Tokza’s public catalog returned 456 model records. The authorization guard was observed for Models, Chat Completions, Responses, Embeddings and Images. These checks did not use a real key and do not prove a successful downstream model call, price, latency or route availability for every account.

Observed

Direct public Tokza HTTP behavior.

Catalog-declared

A model-level compatibility label, not a universal promise.

Standard-compatible

A common interface shape; confirm the selected model supports it.

Conditional

Confirm the exact account-visible route and schema before use.

01

Getting started

Authentication

Tokza account sessions and Tokza API keys are different credentials. Use the account portal to create, name, limit and revoke API keys. Send an API key only in the HTTPS Authorization header; never put it in a browser bundle, source repository, URL or prompt.

  1. 1
    Create an account

    Register at api.tokza.ai/register or sign in.

  2. 2
    Create a scoped API key

    Use a clear name, the smallest necessary access, and an account/workspace spend limit where available.

  3. 3
    Store it server-side

    Load it from a protected secret manager or environment variable and rotate it after suspected exposure.

Bearer authentication
Authorization: Bearer $TOKZA_API_KEY
Keep keys private. Tokza cannot protect a key embedded in frontend JavaScript, a mobile binary or a public repository. Route browser and mobile requests through your own backend.
02

First request

Quickstart

Call GET /v1/models first and select a model returned to your key. The examples use gpt-4o-mini only as an illustrative model observed in the public catalog on August 14, 2026.

cURL
curl https://api.tokza.ai/v1/chat/completions \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

Common response envelope

For Chat Completions, read generated text from choices[0].message.content. Store the response id, selected model, and usage fields when returned; exact usage fields can vary by route.

Illustrative response
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "model": "gpt-4o-mini",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "Hello from Tokza."},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 14, "completion_tokens": 5, "total_tokens": 19}
}
03

Routing

Base URLs and formats

The primary integration surface is the OpenAI-compatible base below. Do not append a second /v1 when an SDK accepts a complete base URL.

BASEhttps://api.tokza.ai/v1Observed
InterfaceUse it whenAvailability rule
OpenAI compatibleChat, common SDKs, embeddings, images and compatible tools.Model is returned to your key and marked openai.
ResponsesYou need item-based inputs/outputs or a Responses-compatible model.Model is marked openai-response.
Native AnthropicYour application requires an Anthropic-native message contract.Model is marked anthropic; confirm the exact account-visible base and route.
Native GeminiYour application requires Gemini-native content parts.Model is marked gemini; confirm the exact account-visible base and route.
Provider-specific mediaA model uses asynchronous video, music or image operations.Use only the route and schema displayed for that model in your account.
04

Discovery

Models and capability labels

Model names, availability and supported formats change. Make GET /v1/models part of onboarding and cache the result briefly rather than shipping a permanent list.

GET/v1/modelsObserved
Discover models
curl https://api.tokza.ai/v1/models \
  -H "Authorization: Bearer $TOKZA_API_KEY"
Capability is model-level. The public catalog exposes supported_endpoint_types. A model can be OpenAI-compatible without supporting Responses, native Anthropic, native Gemini, images, audio or another specialized format.

Catalog-declared On August 14, 2026, the public catalog contained labels for OpenAI, Responses, Anthropic, Gemini, image generation/editing, speech, embeddings, rerank, realtime and asynchronous media. Treat those labels as routing hints and validate a capped request before production.

05

Text and chat

Chat Completions

POST/v1/chat/completionsObserved

Send an ordered messages array. Common roles are system, user, assistant and tool, but accepted fields and limits depend on the selected model.

Chat request
{
  "model": "gpt-4o-mini",
  "messages": [
    {"role": "system", "content": "Answer concisely."},
    {"role": "user", "content": "Give me three names for an analytics feature."}
  ],
  "temperature": 0.3,
  "max_tokens": 120
}
FieldRequiredGuidance
modelYesUse an ID returned to your API key.
messagesYesOrdered conversation state; resend the history needed for the next turn.
temperatureNoSupport/range can vary. Omit it when a reasoning model rejects sampling controls.
max_tokensNoSome models use a different output-token field. Follow the selected model contract.
streamNoSet true only if the route/model supports streaming.
06

Item-based generation

Responses API

POST/v1/responsesObserved

Use Responses only with a model marked openai-response. Its input/output items differ from Chat Completions; do not assume choices[0] exists.

Responses request
curl https://api.tokza.ai/v1/responses \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "input": "Explain exponential backoff in 50 words."
  }'
Parse by item type. Preserve unknown item types, status and usage fields. A model may expose reasoning, tool calls or other typed output rather than one plain text field.
07

Incremental output

Streaming and conversation state

Standard-compatible For compatible routes, set stream: true and consume Server-Sent Events until the terminal event. Event payloads differ between Chat Completions and Responses.

Python streaming
stream = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Write a two-line poem."}],
    stream=True,
)

for event in stream:
    delta = event.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
  • Treat a connection close before a terminal event as incomplete.
  • Do not automatically replay a request after partial output when duplicate spend or side effects matter.
  • Record request ID, model, attempt number and whether a terminal usage record arrived.
  • For multi-turn Chat Completions, your application owns the message history and token budget.

Realtime sessions

POST/v1/realtimeCatalog-declared

The public catalog maps its realtime capability to this route. Before adoption, confirm the authenticated session bootstrap, transport, ephemeral-key policy, event names, audio formats and termination behavior for the selected model. A catalog path alone does not establish a WebSocket or WebRTC contract.

08

Controlled output

Tools and structured outputs

Standard-compatible Tool calling and JSON-schema output are model-dependent. Validate support with the selected model and never execute tool arguments without application authorization and schema validation.

Tool declaration
{
  "model": "gpt-4o-mini",
  "messages": [{"role": "user", "content": "Weather in Rome?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Return current weather for one city",
      "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"],
        "additionalProperties": false
      }
    }
  }]
}

Validate the tool name and arguments, enforce per-user authorization, execute the function in your application, then send a tool-result message tied to the returned call ID. Model selection is not permission to perform the action.

09

Multimodal input

Vision

Conditional Use image content only with a model whose account-visible contract supports vision. Prefer short-lived HTTPS URLs or accepted data URLs, and do not assume every OpenAI-compatible chat model accepts image parts.

Standard-compatible vision message
{
  "model": "<VISION_MODEL_FROM_V1_MODELS>",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Describe the chart."},
      {"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}
    ]
  }]
}

Confirm accepted MIME types, size limits, URL-fetch policy, detail controls and retention before sending sensitive media.

10

Retrieval

Embeddings and reranking

POST/v1/embeddingsObserved
Embedding request
curl https://api.tokza.ai/v1/embeddings \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"<EMBEDDING_MODEL_FROM_V1_MODELS>","input":["First document","Second document"]}'

Store the exact model ID and vector dimension with every embedding batch. Do not mix vectors from different models or silent model revisions in one index.

POST/v1/rerankCatalog-declared

The public catalog maps rerank-labelled models to /v1/rerank. Confirm the selected model’s document/query fields, maximum document count, score direction and response schema; test ranking order on a fixed fixture before production.

11

Generation and editing

Images

POST/v1/images/generationsObserved
POST/v1/images/editsCatalog-declared
Standard-compatible image request
curl https://api.tokza.ai/v1/images/generations \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<IMAGE_MODEL_FROM_V1_MODELS>",
    "prompt": "A clean isometric diagram of an API gateway",
    "size": "1024x1024"
  }'

Response format, size options, moderation, input images, masks, edit endpoints and URL expiry are model-specific. Download generated assets promptly and retain provider/model/request metadata needed for audits.

12

Speech

Speech-to-text and text-to-speech

Catalog-declared Tokza’s public catalog included speech-to-text, text-to-speech, synchronous speech and asynchronous speech labels. Exact model, voice, file-size and format support must be confirmed per account.

POST/v1/audio/transcriptionsCatalog-declared
POST/v1/audio/speechCatalog-declared
Conditional speech-to-text pattern
curl https://api.tokza.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -F "model=<TRANSCRIPTION_MODEL_FROM_V1_MODELS>" \
  -F "file=@meeting.mp3"
Conditional text-to-speech pattern
curl https://api.tokza.ai/v1/audio/speech \
  -H "Authorization: Bearer $TOKZA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"<TTS_MODEL_FROM_V1_MODELS>","voice":"<SUPPORTED_VOICE>","input":"Hello from Tokza."}' \
  --output speech.mp3

Do not log raw audio by default. Validate consent, voice rights, accepted formats, maximum duration and retention before uploading customer recordings.

13

Provider compatibility

Native Anthropic and Gemini formats

Catalog-declared The public catalog included model-level anthropic and gemini labels. Those labels do not mean all Tokza models accept native provider SDKs or preserve every provider-specific field.

POST/v1/messagesAnthropic mapping
POST/v1beta/models/{model}:generateContentGemini mapping
Before using a native formatRequired check
Base URL and routeUse the catalog mapping only with a model declaring the matching endpoint type; confirm it in your authenticated account.
Model IDUse the Tokza-visible ID, not an assumed upstream alias.
Headers and versionsConfirm whether provider-specific version headers are required or translated.
Streaming/eventsContract-test event types, terminal state, errors and usage fields.
Tools, caching and reasoningVerify field preservation and billing behavior with a capped fixture.
Declared path, conditional contract. These paths were present in Tokza’s public catalog mapping, but their provider-version headers, request schema, streaming events and supported fields were not exercised with a real key.
14

Long-running work

Asynchronous media tasks

Conditional Video, music and some image/audio models use submit-and-poll workflows. Tokza’s catalog declares multiple media formats, but task paths, status values, callback signatures and cancellation rules vary by model family.

Catalog familyDeclared submission routeWhat remains model-specific
Unified video formatPOST /v1/video/createPayload, task state, status lookup and output schema.
OpenAI official video formatPOST /v1/videosSupported models, inputs, polling/events and edits.
Official video formatPOST /v1/videos/generationsAccepted fields, task lifecycle and asset expiry.
Provider-specific mediaUse the path paired with the model’s exact catalog label.Every payload and lifecycle field; do not translate by name alone.
1Submit

Send the exact account-visible payload with an idempotency key if supported.

2Persist task ID

Store request ID, task ID, model, input hash, attempt and submitted time.

3Poll or receive callback

Use bounded backoff. Authenticate callbacks and reject replayed or stale events.

4Reconcile

Confirm terminal status, output URLs, expiry, usage and balance before resubmitting.

Never assume a timeout means the task failed. A create request can complete upstream after your connection closes; query the known task or reconcile account usage before creating another.

15

Clients and tools

SDKs and integrations

Any client that accepts an OpenAI-compatible base URL and bearer key can be evaluated with Tokza. Support still depends on the specific endpoints and fields that client uses.

OpenAI SDKs

Set base_url or baseURL to https://api.tokza.ai/v1. Start with Chat Completions unless the selected model declares Responses support.

LangChain

Configure an OpenAI-compatible chat model with the Tokza base URL. Pin the model ID and test streaming, tools and usage metadata separately.

LlamaIndex

Configure the LLM and embedding clients independently; they may require different model IDs and capability labels.

Developer tools

For Cursor, OpenCode, Cline, n8n or similar tools, use their custom OpenAI-compatible provider option. Confirm whether the tool appends /v1 automatically.

Generic environment configuration
TOKZA_API_KEY=<TOKZA_API_KEY>
OPENAI_API_BASE=https://api.tokza.ai/v1
OPENAI_BASE_URL=https://api.tokza.ai/v1
A base-URL field is not full compatibility. Validate the exact client journey: model listing, request body, streaming parser, tools, images/audio uploads, error parsing and usage reporting.
16

Reliability

Errors, rate limits and retries

Use the HTTP status and structured error type as the primary control signal. Preserve Tokza’s request identifier from errors and response headers when available; human-readable messages may be localized or change.

StatusMeaningSafe default
400Malformed or unsupported request.Do not retry unchanged. Fix fields/model/format.
401Missing, invalid or revoked API key.Do not retry. Verify secret source and rotation state.
402Insufficient balance or billing restriction.Stop. Review account balance and billing.
403Key/account lacks permission for this route or model.Stop. Check key scope and model entitlement.
404Unknown route, model or task.Stop. Refresh discovery and verify the task/account boundary.
409Conflict or duplicate state.Reconcile the existing task/request before resubmitting.
422Semantically invalid payload.Do not retry unchanged. Correct validation errors.
429Rate limit or abuse protection.Honor Retry-After; back off with jitter and reduce concurrency.
500Internal failure.Retry only transient, pre-execution-safe requests with a limit.
502Upstream/gateway failure.For billable or async creates, reconcile before retrying.
503Temporarily unavailable or overloaded.Back off, apply a retry budget and use an approved fallback.
504Gateway timeout; execution state may be unknown.Reconcile by request/task ID and usage before resubmitting.
Bounded retry sketch
for attempt in range(4):
    try:
        return call_tokza()
    except RateLimitError as error:
        wait = error.retry_after or min(8, 2 ** attempt)
        sleep(wait + random.uniform(0, 0.25))
    except (BadRequestError, AuthenticationError, PermissionDeniedError):
        raise
raise RuntimeError("Tokza retry budget exhausted")

Apply an end-to-end deadline shorter than your user-facing timeout. Do not stack SDK retries, proxy retries and application retries without one shared attempt budget.

17

Production checklist

Security and operations

Keys

  • One key per environment or workload.
  • Store in a secret manager.
  • Rotate after exposure and during staff/offboarding changes.
  • Never log the header or full key.

Spend

  • Set account/workspace caps where available.
  • Enforce application budgets by user and tenant.
  • Alert on request, token and cost anomalies.
  • Reconcile provider usage with Tokza balance/account records.

Observability

  • Log request ID, model, route, latency and status.
  • Record attempt/fallback number and terminal state.
  • Capture usage fields without prompts or credentials.
  • Separate gateway latency from model latency when possible.

Data

  • Minimize personal and confidential input.
  • Review applicable retention and subprocessor terms.
  • Redact secrets before model calls.
  • Apply tenant isolation before sharing tools or retrieval data.

Before production traffic

Content moderation

POST/v1/moderationsCatalog-declared

Tokza’s catalog maps a moderation capability to this route. Confirm which moderation model is available, the category/score schema and whether media is supported. Moderation is one control layer; keep application authorization, abuse monitoring and human escalation for consequential decisions.

Documentation evidence reviewed . Model availability and account contracts can change; authenticated discovery wins over this dated guide.