Skip to navigation

Connection and usage

View as Markdown

Most connection failures come from the base URL, the Authorization header or the account balance. Use the right host (https://direct.beatapi.io for text calls, https://api.beatapi.io for everything else), send the key as Authorization: Bearer <key>, and match the HTTP status and error code of the failing response to a section on this page. Include the request_id from the failing response in any support ticket.

Which base URL should I use?

Use https://direct.beatapi.io for text calls (Chat Completions, Responses, Messages and Gemini native): it is not subject to Cloudflare’s 100-second limit, so a long non-streaming request is not cut off. Use https://api.beatapi.io for images, video, effects, workflows, files, usage, webhooks and capabilities, and as the fallback for text if direct.beatapi.io is unreachable from your network. The key is the same on both. The examples below use api.beatapi.io; swap in direct.beatapi.io for text. Whether the base URL ends in /v1 depends on the path that your client appends:

Calling from Asia? If requests to api.beatapi.io from your network drop the connection or time out without returning any HTTP status (Python reports RemoteDisconnected or URLError), use https://api-asia.beatapi.io. It serves the same API (text, images, video, files, tasks, usage and webhooks) with the same key and the same paths, on a route tuned for Asia-Pacific networks; replace the host in the table below and keep everything else.

Client styleBase URLBecause it appends
OpenAI SDK and OpenAI-compatible toolshttps://api.beatapi.io/v1/chat/completions
Anthropic SDK and Claude-native toolshttps://api.beatapi.io/v1/messages
Gemini SDK and Gemini-native toolshttps://api.beatapi.io/v1beta/models/...
Raw HTTPFull path, e.g. https://api.beatapi.io/v1/chat/completionsnothing

A wrong base URL produces a 404 on every request, and most clients report the 404 as “cannot connect” rather than as a bad URL.

Everything returns 404

Check these four causes, most likely first:

  1. A doubled or missing /v1. Compare your base URL with the table under Which base URL should I use?. /v1/v1/chat/completions does not exist.
  2. A trailing slash on the base URL, which some clients concatenate literally.
  3. An endpoint that is not part of the published surface. BeatAPI publishes a deliberate list: text, tasks, files, usage, webhooks, and realtime. Endpoints outside the published list return 404 rather than an error, on purpose. /v1/embeddings, /v1/rerank, and /v1/audio/* are not served.
  4. A model ID that does not exist. IDs are case-sensitive and carry no vendor prefix: use claude-fable-5-1, not anthropic/claude-fable-5-1.

401 missing_api_key or invalid_api_key

missing_api_key means no key reached BeatAPI. invalid_api_key means a key arrived but is wrong, expired, disabled, or has used up its own quota; the error message names the reason. Older clients may still show the legacy name unauthorized for both codes.

  • The header is Authorization: Bearer <key>. A missing Bearer prefix reads as a malformed key.
  • Whitespace pasted around the key counts as part of the key.
  • Confirm the key is still active in Dashboard → API Keys. A revoked key fails immediately and permanently.
  • Some clients send the key in an x-api-key or x-goog-api-key header instead. BeatAPI accepts both headers, and every header form identifies the same account and the same balance.

403 forbidden

Authentication succeeded, but the account or the key is not allowed to perform the operation. Check the key’s own restrictions (its IP allowlist and the group of models it may call) and the account’s status before looking at the request. On an account that has only free credit, models outside the free list answer 403 forbidden with a message saying so; a top-up enables access to those models.

A 403 from BeatAPI is always BeatAPI’s own decision; a model’s answer is never passed through as a 403. (A 403 whose body is error code: 1010 came from the network edge instead: set an explicit User-Agent.) A prompt refused by content moderation is 400 content_policy_violation at create, or content_policy_violation in error_code on an accepted task. See Errors.

402 insufficient_credits

The balance is zero or below the price of the request, or the key still has quota but less than the price. Every paid operation on the account fails with 402 until credits are added; the block applies to the whole account, not to one key. Insufficient balance returns 402 on every endpoint. If your users call BeatAPI through your product, set an alert on 402 responses.

429 rate_limit_exceeded

A request-rate limit returns 429:

  • Request rate: Too many requests per minute for this account. Honour Retry-After or retry_after_seconds. The allowance rises with lifetime top-ups, except on free models, which have their own fixed limit: 1 successful request per minute before your first top-up, up to 10 per minute after any top-up, counted separately from the paid allowance.

Polling does not cause a 429: GET /v1/tasks/{task_id} is not subject to the request-rate limit. A burst of task creates or text calls can. Poll at the poll_after_seconds the response gives and spread your creates; see the Development Guide.

A request times out

Text calls with stream: false return nothing until the model has finished, and a long reasoning response can take a while. Two changes prevent the timeout:

  • Stream. With stream: true the first bytes arrive quickly and the connection stays active throughout.
  • Raise the client timeout. Many SDKs default to 30 or 60 seconds, which is short for a long non-streaming completion.

A task never finishes

Read the task status instead of waiting longer. GET /v1/tasks/{task_id} returns one of a fixed set of states, and two of the states do not mean “still working”:

  • storyboard_ready and requires_action on Music Video tasks are waiting for you, not for the model. Polling a task in either state does not advance the task.

Everything else is either terminal (succeeded, failed) or genuinely in progress. See the Quick Guide for the full table.

Connections fail from a server but work from my laptop

Test from the machine that actually makes the call. Self-hosted platforms (Dify, AnythingLLM in Docker, CI runners) have their own egress rules. Confirm the container or host can reach api.beatapi.io and direct.beatapi.io, and allow it through any corporate proxy.

What do I include in a bug report?

Include the request_id from the failing response. Every BeatAPI error carries a request_id, and the request_id identifies the exact call in the logs. Add the model ID, the endpoint, and the approximate time. Open a ticket from the dashboard or email support@beatapi.io.