FunkyRouter DocsBeta

Errors and limits

Error format, HTTP status codes, request limits and billing for incomplete requests.

Error format

All errors use this JSON body:

{
  "error": {
    "message": "The request is invalid.",
    "type": "invalid_request_error",
    "code": "funkyrouter_invalid_request",
    "request_id": "…",
    "status": 400,
    "retryable": false
  }
}

Use code in your error handling. Do not use message, because its text can change. If retryable is true, you can send the request again.

Status codes

StatuscodeCauseRetry
400funkyrouter_invalid_requestA field is not accepted or out of range, the model ID is incorrect, an image is not accepted, or the prompt plus maximum output is more than the context window.No
401funkyrouter_unauthorizedThe key is missing, incorrect or revoked, or the request has more than one authorization header.No
402saddle_requiredThe workspace has no active FunkyRouter Credits plan.No
402funkyrouter_insufficient_creditsThe workspace does not have sufficient credit.No
402funkyrouter_customer_budget_exceededA customer budget stops the request.No
403funkyrouter_forbiddenThe key is a management key.No
404funkyrouter_not_foundThe path is not a public API path.No
405funkyrouter_method_not_allowedThe HTTP method is incorrect.No
413funkyrouter_request_too_largeThe body is too large.No
415funkyrouter_unsupported_media_typeThe Content-Type is not application/json, or the body is compressed.No
429funkyrouter_rate_limitedThe workspace sent too many requests.After Retry-After
429funkyrouter_capacity_unavailableAll nodes are busy.Yes
502funkyrouter_upstream_errorThe model service sent an incorrect response.Yes
503funkyrouter_unavailableNo node is ready.Yes
504funkyrouter_timeoutThe request did not complete in the time limit.Yes

An unknown model ID gives HTTP 400, not 404.

For retries, wait before each attempt and increase the wait each time. When the response has a Retry-After header, wait for that number of seconds.

Limits

LimitValue
Context window1,048,576 tokens, prompt plus output
Maximum outputUp to the context window, less the prompt. No default.
StreamingNecessary when the prompt is more than 131,072 tokens. If not, the API returns HTTP 400.
ImagesBase64 data URLs of PNG, JPEG, GIF or WebP, in user messages only. Each side 40 to 4,096 pixels. A remote URL or a file_id gives HTTP 400.
Messages or input items64 per request
Tools64 per request
Request body8 MiB. Over the limit, the API returns HTTP 413.
Request time300 seconds, plus more time for long prompts and long output. 2 hours at most. Over the limit, the API returns HTTP 504, or an error event in a stream.
Request rateA limit for each workspace. Over the limit, the API returns HTTP 429 with Retry-After.

A response that is not streamed sends nothing until it is complete. The connection can close after approximately 100 seconds. Stream long answers.

A long prompt takes time before the first token. When a stream has no output after 15 seconds, the gateway opens the stream and keeps it open. After that, an error comes as an error event in the stream, not as an HTTP status.

When all nodes are busy, the gateway holds a request in a queue for a short time. If no node becomes free, the API returns HTTP 429 with funkyrouter_capacity_unavailable.

Response headers

HeaderContent
X-Request-IDA unique ID for the request. Give it when you report a problem.
X-FunkyRouter-RegionThe region that served the request, for example texas.
Retry-AfterSeconds to wait. Sent with some 429 responses.

Billing for incomplete requests

When a node reports token usage, FunkyRouter charges that usage. When a node does not report usage, FunkyRouter estimates it from the size of the request and the output:

EventCharge
You cancel after a node accepted the requestInput and all output that the node made
The time limit ends, streamed requestInput and the output that you received
The time limit ends, request not streamedInput only
The node fails after it sent output, streamed requestInput and the output that you received
The node fails, request not streamedNo charge
The request fails before a node accepts it or before output startsNo charge

The charge is never more than the credit that the gateway reserved for the request.

Last updated on

On this page