Skip to content
Docs

REST API

Errors

Every refusal carries a stable, machine-readable code. Branch on the code, show the message to a human, and never parse the message.

Envelopes#

LeanConnect (web search, email, connectors), LeanData, LeanMachine, LeanVision, LeanMemory, model tiers and the tools API#

{ "isSuccess": false, "errorMessage": "The account has no credits left. Top up or renew the subscription to continue.", "errorCode": "insufficient_credits" }

A data query answered as a JSON page may add usage when rows were fetched before the failure; a NDJSON stream that fails after its header ends with an {"error":{code,message,status},"usage":{…}} line. A held connector write adds details { approvalId, expiresUtc, pollUrl }.

OpenAI-compatible endpoints#

{ "error": { "message": "…", "type": "insufficient_quota", "code": "insufficient_credits" } }

LeanBrowser#

{ "error": "Description of the error.", "statusCode": 400 }

MCP#

Protocol failures are JSON-RPC errors ({ jsonrpc, id, error: { code, message, data } }); tool failures are results with isError: true whose text is {"error":{"code","message","status"}}.

Admission codes (every service)#

StatusCodeMeaningWhat to do
401authentication_errorMissing, unknown or revoked API keySend Authorization: Bearer lt-…; create a key in the console
401key_expired, key_revokedThe key passed its expiry date, or was revoked (a held call approved after the fact fails with key_revoked)Rotate or recreate the key in the console
402insufficient_creditsThe workspace has no credits left (or the in-flight reserve is exhausted)Reload credits or turn on auto-reload
402key_cap_reachedThe key reached its monthly spend capRaise the cap or use another key
402tool_budget_reachedThe tool reached its monthly budget with pausing onRaise the budget or turn pausing off
403service_not_allowedThe key is not scoped to this serviceEdit the key's access
403tool_disabledThe tool is switched off for the workspaceEnable it under Tools & Connectors
403account_suspended, account_closedThe workspace is not activeContact support
429too_many_requestsRate limited at the edgeHonour Retry-After

Connector and approval codes#

StatusCodeMeaning
202approval_pendingThe write is held for a human; poll /api/v1/connectors/approvals/{id}
400invalid_request, invalid_input, unknown_field, credential_required, invalid_credential, approval_requires_stored_credential, oauth_not_supported, expressions_not_supportedBody shape, input validation, credential problems; a held write needs a stored credential, not an inline one
403connector_disabled, connector_paused, action_disabled, key_not_allowed, transport_not_allowedHost catalogue switch, workspace pause, workspace guardrails
404connector_not_found, action_not_found, credential_not_found, credential_type_not_found, approval_not_found
413payload_too_large
422connector_errorThe upstream rejected the request
429rate_limited, daily_cap_reachedPer-connector limits set in the console
502 / 504connector_upstream_error, connector_timeout

LeanData codes#

See the LeanData status codes: invalid_filter, subscription_required, dataset_not_found, response_too_large, provider_error and the others.

LeanModel (OpenAI envelope)#

CodeMeaning
authentication_errorInvalid, missing or revoked API key
invalid_request_errorMalformed request
model_not_foundThe named tier does not exist (404), or the catalogue has no usable tier (400); use GET /api/v1/models/tiers
model_not_configuredThe tier exists but the operator has not bound a model to it yet (400), for example a standard tier (leanmodel-flash, leanmodel-default) on a new host
capability_not_supportedThe tier's model cannot take this request (400): image or audio parts on a tier without vision or hearing, an edit on a tier without image input, transcription on a tier that does not offer it
unsupported_parameterA field LeanModel does not pass on (400), such as mask on image edits
invalid_inputMalformed media (400): bad base64, an audio format other than wav or mp3, a clip or upload over the size limit
tier_not_in_packageThe package does not price the tier (403)
insufficient_creditsNo credits left (402, type insufficient_quota). On a realtime audio socket the relay sends it as an error event (error.code is insufficient_credits) and closes with code 1008
too_many_streams, too_many_socketsThe workspace's cap on open avatar streams or realtime sockets is reached (429)
stream_not_foundNo avatar stream with that id belongs to the workspace (404)
stream_closedThe avatar stream has already been closed (409); create a new one
stream_not_readyThe avatar stream is still being created (409); retry in a moment
upstream_errorThe avatar provider refused or failed the call (502); a stream that could not be created is not charged
model_unavailable, billing_unavailableThe avatar's model is no longer set up, or billing could not be opened and the new stream was closed again (503); retry
upstream_unavailableThe realtime model could not be reached (502, answered before the WebSocket upgrade); nothing is charged
websocket_requiredThe realtime endpoint was called without a WebSocket upgrade (400)
server_errorThe AI provider failed

Embeddings (POST /api/v1/embeddings) answer in the same envelope with their own codes: invalid_input (400), payload_too_large (413), not_configured (503, no embedding model set up on the host) and upstream_error (502, the model failed; nothing is charged), besides the admission codes above.

LeanBrowser statuses#

StatusMeaning
400Bad request (invalid JSON, missing fields)
401 / 402 / 403Credential, credits, scope or workspace status
404Route not matched, or a session that is not yours
408Request timeout
413Payload too large
429too_many_sessions: concurrent WebSocket limit (default 4 per workspace)
503System overloaded

LeanMachine, LeanVision and LeanMemory#

Those services have their own vocabularies (duplicate_key, no_capacity, too_many_streams, policy_refused, storage_cap_exceeded, quota_exceeded, upstream_error, upstream_timeout, …), listed with each service in the reference.

Updated October 14, 2026 · This page as Markdown · All docs as one file