Error handling
Ship integrations that keep working when the API returns an error, hits a rate limit, or fails transiently. Meta Model API uses standard HTTP status codes and returns a descriptive error object that points to the problem.
Error response format
A failed request returns a JSON error object:
json{"error": {"message": "`top_p`: The number must be `<= 1.0`.","type": "invalid_request_error","param": "top_p","code": null}}
| Field | Type | Description |
|---|---|---|
message | string | Human-readable detail. This is the most reliable field for diagnosis. |
type | string | Error category: invalid_request_error for 4xx validation and not-found errors, authentication_error for 401, rate_limit_error for 429, or server_error for 5xx. |
param | string or null | Request field that caused the error, when applicable, such as top_p or tools. |
code | string or null | Machine-readable code. Frequently null on validation errors, so prefer type and message for handling. Populated for cases such as invalid_api_key, model_not_found, file_not_found, rate_limit_exceeded, server_shutting_down, service_overloaded, backend_unavailable, payload_too_large for a request body over a size limit, gateway_timeout (a non-streaming request that ran past the server-side time limit), and content_policy_violation for a media content-policy denial. |
HTTP status codes
400 Bad Request
The server could not process the request because a parameter was missing or invalid.
Common causes:
- Missing required parameters such as
modelormessages - Invalid parameter values such as
temperatureoutside the 0–2 range, ortop_poutside0 < top_p ≤ 1, includingtop_p: 0 max_output_tokensbelow the minimum of 16 on the Responses API- Request input plus the requested output budget exceeds the model's context window:
input_tokens + max_output_tokensmust fit within it (see Context window exceeded) - Uploading or inlining a file larger than the size limit (up to 1 GiB via the Files API, 50 MB inline)
- Combining mutually exclusive features
- Declaring a function tool whose name collides with a built-in tool name reserved by
web_search(returnsparam: tools) - Invalid JSON in request body
- Duplicate
reasoning_idvalues in Responses API requests - Invalid conversation structure, such as a
function_call_outputwhosecall_idmatches nofunction_call, a replayedreasoningitem not followed by an assistant message orfunction_call, or intermediate assistant text replayed before afunction_callwithoutphase: "commentary"(see Invalid conversation structure) - Invalid message structure such as empty input, or unsupported role/turn combinations that violate the model's input-shape requirements
- Submitting media (a file, image, or inline content) that does not meet Meta's content policy; returns
code: content_policy_violation - Providing an image or media URL that cannot be fetched: for example, blocked by
robots.txt, denied by fetch policy, failing DNS resolution, or otherwise unreachable. The error message identifies the specific fetch failure, for example an unreachable URL or arobots.txtdenial - Submitting a corrupt or truncated image whose bytes cannot be decoded; the error message identifies the affected image (
type: invalid_request_error,code: null) - Submitting an audio or video file that cannot be decoded: for example, an audio container with no audio track, a format the decoder does not recognize, or empty/corrupt media. The error message identifies the decode failure (
type: invalid_request_error,code: null)
Fix: Read message and param to identify the problem. code is typically null for validation errors. Check the API reference for valid parameter combinations.
401 Unauthorized
The API key was missing, invalid, or revoked.
Common causes:
- Missing
Authorizationheader - Malformed API key (not in
LLM|{id}|{secret}format) - Revoked or deleted API key
- Typo in the API key
curlcurl -X POST "https://api.meta.ai/v1/chat/completions" \-H "Content-Type: application/json" \-d '{"model": "muse-spark-1.3", "messages": [...]}'
json{"error": {"message": "Unauthorized","type": "authentication_error","param": null,"code": "invalid_api_key"}}
Both a missing key and an invalid, malformed, or revoked key return type: authentication_error with code: invalid_api_key.
Fix: Send a valid Authorization: Bearer $MODEL_API_KEY header. Verify the key in the Model API dashboard and that MODEL_API_KEY is set correctly. See Authentication for setup.
402 Payment Required
The request cannot be completed due to a billing issue.
Common causes:
- Insufficient balance or a lapsed payment method
- Billing account issue
json{"error": {"message": "Billing account issue. Please check your account status.","type": "billing_error","param": null,"code": "billing_not_configured"}}
Fix: Check account status and billing details in the Model API dashboard. Ensure your payment method is valid and your balance is sufficient.
403 Forbidden
The API key does not have permission to access the requested resource.
Common causes:
- API key lacks permission for the requested model or feature