API Docs

FAQ & Troubleshooting

The most common errors and questions when integrating UnioAPI — authentication failures, insufficient balance, wrong protocol or model, context limits, rate limits, timeouts and leaked keys.

When something goes wrong, start with the HTTP status and the error type in the response, then follow the sections below. Every response carries an X-Request-ID header — include it when you contact support. The full mapping is in Errors.

Authentication and account

401: invalid key

The three usual causes

The key was copied incompletely (extra spaces or line breaks); the environment variable is not set in the current terminal; or the key was revoked, disabled or has expired.

  1. Run echo $UNIO_API_KEY and confirm it prints the full key.
  2. On Windows, variables written with setx only apply to newly opened terminals — close and reopen it.
  3. Check the key's status and expiry on the API Keys page of the console.
  4. Use one of the two headers: Authorization: Bearer <key> or x-api-key: <key>. The Bearer prefix is case-sensitive.

402: insufficient balance or the key reached its spend cap

There are two cases; the response code tells them apart:

codeMeaningWhat to do
credit_balance_exhaustedThe account balance is too lowTop up by redeeming a CDKEY under Wallet; see Console & top-up
insufficient_quotaThis key's lifetime usage reached the spend cap set when it was createdRaise the cap on the API Keys page, or use another key

In the Anthropic shape, a key that reached its spend cap returns 400 invalid_request_error. New accounts start with a zero balance — top up before your first call, otherwise the very first request returns 402.

429 although the balance is positive

If the 429 carries Retry-After: 1, the balance is briefly held by requests that are still in flight. Retry after a second. Other 429 sources and how to handle them are in Rate limits.

Protocols and base URLs

Does the base URL include /v1?

Client typeBase URL
OpenAI protocol (OpenAI SDK, Codex, Cursor, Cline …)https://api.unioapi.com/v1
Anthropic protocol (Anthropic SDK, Claude Code, the Claude app)https://api.unioapi.com

Anthropic-protocol clients append /v1/messages themselves, so adding /v1 produces /v1/v1/messages. OpenAI-protocol clients are the opposite: without /v1 they call a path that does not exist. A wrong base URL usually shows up as a 404.

Which protocol should I use for GPT and Claude models?

  • gpt-* models use the OpenAI protocol: POST /v1/chat/completions or POST /v1/responses.
  • claude-* models use the Anthropic protocol: POST /v1/messages, with an anthropic-version header.

The same key works for both. The endpoints each model actually supports are listed in endpoint_capabilities from GET /v1/models. See Choose a Protocol for the full comparison.

Models

404 model_not_found

  • The model ID is misspelled. UnioAPI model IDs match the vendor's official IDs without a vendor prefix: gpt-5.6-sol, not openai/gpt-5.6-sol.
  • The model was retired, or cannot be called through this endpoint — for example a GPT model through Messages.
  • A coding tool's default model name does not exist on UnioAPI. Set the model explicitly as each client page describes.

GET /v1/models returns every model ID you can call right now.

"Only supported in v1/responses"

gpt-5.5-pro, gpt-5.4-pro and gpt-5.2-pro can only be called through the Responses API. Chat Completions returns 404 for them — switch to POST /v1/responses. See Choose a Protocol.

400 after turning on Fast

The model does not offer the Fast tier. Pick a model that does, or remove service_tier / speed to send the request as Standard. Tiers per model are on the model pages and in Service tiers.

Requests and responses

400 context_length_exceeded

The input is larger than the model's context window (in the Anthropic shape the message starts with prompt is too long: ). Start a new session, trim old messages, attach fewer files at once, or use a model with a longer window. How long inputs above a threshold are billed is described in Long context.

Slow requests or timeouts

  • Reasoning models at high effort can take a while before the first token. Turn on streaming to see progress early.
  • If the client's own timeout is too short it disconnects before the server finishes. Use several minutes for long tasks.
  • A server-side processing timeout returns 504; a temporarily overloaded model returns 503 (OpenAI shape) or 529 (Anthropic shape). Retry later.

The stream stopped midway

Without the end marker ([DONE] for Chat Completions, message_stop for Messages, the terminal event for Responses) the stream did not complete — treat it as unfinished. An interrupted stream is billed for the output already delivered. See Streaming and Billing & usage.

Billing and usage

I sent one message — why are there several request logs?

One action in a coding agent usually means several model calls: understanding the task, reading files, calling tools and reasoning again. Every real call creates a request log. See Usage & billing records for how to check them.

Are failed requests charged?

Requests rejected before execution (400, 401, 402, 404, 429 …) are free, and so are requests that fail before producing any output. The full rules are in Billing & usage.

Security

My key leaked

  1. Revoke it on the API Keys page right away; revocation takes effect immediately.
  2. Create a new key and put it into your environment variables or configuration.
  3. Use Request logs to review calls made with that key prefix while it was exposed.

Give every key a spend cap and an expiry, and split keys by purpose, so a leak has a smaller blast radius.

Still stuck?

Open a ticket under Feedback tickets in the console with the X-Request-ID, the request time and the model.