Docs / Errors

Errors

Every error the API returns, and whether you were charged.

Unspent's own errors use the Anthropic format on /v1/messages:

json
{ "type": "error", "error": { "type": "billing_error", "message": "Not enough credits. …" } }

and the OpenAI format on /v1/chat/completions:

json
{ "error": { "message": "Not enough credits. …", "type": "insufficient_quota", "code": "insufficient_credits" } }

None of them is charged. Messages say what happened and what to do.

Gateway errors

StatusAnthropic typeOpenAI codeWhen
400invalid_request_errorinvalid_requestThe body is not a JSON object, or Idempotency-Key is not 8–128 characters
400invalid_request_errorunsupported_parameterA tool type or field Unspent doesn't offer, see Messages API
400invalid_request_errormodel_not_foundThe model is not on Unspent, or the key doesn't allow it
400invalid_request_errorrequest_too_expensiveThe worst-case cost is over the per-request limit. Lower max_tokens
401authentication_errorinvalid_api_keyThe key is missing, unknown or revoked
402billing_errorinsufficient_creditsThe hold doesn't fit your available balance. Lower max_tokens or top up
403permission_errorregion_not_supportedUnspent is not available in your country or region
409invalid_request_errorrequest_in_progressA request with this Idempotency-Key is still running
409invalid_request_erroralready_processedA request with this Idempotency-Key already ran. The body has its request_id and credits_charged
409invalid_request_erroridempotency_key_reusedThis Idempotency-Key was used with a different body
410invalid_request_errorservice_shut_downUnspent is shut down. Withdraw and redeem your credits
429rate_limit_errorrate_limit_exceededToo many requests per minute or at once
429rate_limit_errortoo_many_in_flightRunning requests already hold your wallet's hold limit
429rate_limit_errorkey_limit_exceededThe key reached its daily limit
500api_errorinternal_errorUnexpected error. A hold, if one was made, is released automatically
503overloaded_errorreservation_timeoutSolana didn't confirm the hold within 20 seconds
503overloaded_errorreservation_failedThe program didn't accept the hold
503overloaded_errorprovider_unavailableThe model provider is unavailable

In the OpenAI format authentication_error becomes invalid_request_error, billing_error becomes insufficient_quota, and api_error and overloaded_error become server_error.

Most 429 and 503 responses carry retry-after in seconds. Paths that don't exist return 404 not_found_error.

Provider errors

Errors from the model provider are forwarded with their status, body and retry headers unchanged.

Provider errorCharged
400, 413, 422: the provider rejected the request0.001 credit, the minimum charge
401, 403 on Unspent's provider keyNothing. Returned as 503 provider_unavailable
429, 500, 529 and other errorsNothing

Streams that end early

If the provider ends a stream early, you pay for the tokens generated until then. When the final usage is missing, the output is estimated from the text received at 3.5 characters per token, and the request is marked as estimated.