For the complete documentation index, see llms.txt. This page is also available as Markdown.

Request Validation and Error Responses

Public APIs validate requests before performing supported operations. Read the status and error body together to decide whether to correct the request or retry.

Check status and body before retrying

Illustrative backend control flow. Implement the named handlers for your application. Correct rejected inputs or access before retrying; an uncertain run-start response must not trigger a blind second POST.

Copy the example
response = session.post(
    f"{base_url}/v2/runs", json=run_request
)
if response.status_code in (400, 422):
    inspect_validation_error(response.json())
elif response.status_code == 401:
    check_credential()
elif response.status_code == 403:
    check_scope_and_resource_access()
else:
    response.raise_for_status()
    track_created_run(response.json())

Before you begin

The endpoint schema and a way to retain request and run identifiers without logging secrets.

Key concepts

Term
Definition

Validation

A check against supported structure and constraints. Passing validation does not prove that generated answers meet every quality requirement.

Schema

A definition of fields, types, required values, and supported constraints. Use it to validate the shape of data; it does not establish factual correctness.

HTTP status

The numeric outcome returned for an HTTP request. Read the response body too; accepted work can still be running.

Revision conflict

A response indicating that the resource changed since the version used for an edit. Read current state and reconcile changes before resubmitting.

Reconciliation

Checking the run or destination to determine whether an uncertain operation completed. Do this before retrying a write after a timeout.

Handle an invalid API request

  1. Validate required fields, types, and allowed values before sending.

  2. Inspect non-success responses and preserve their error details.

  3. Correct input or access problems before retrying; reconcile uncertain writes first.

The client reports a useful error and avoids repeating invalid or ambiguous operations.

Behavior and limitations

A 2xx response can mean accepted work rather than completed work. A timeout or server error can occur after work starts. Error formats vary by API version. Do not treat every non-success response as a temporary outage or discard the response body.

Condition
Next action

Invalid or missing credential

Correct authentication before repeating the request.

Insufficient access

Check key scope, organization, and resource sharing.

Invalid input

Correct the reported field using the operation’s schema.

State or revision conflict

Read current state and decide whether the operation still applies.

Provider rate limit

Follow the provider’s retry guidance and reduce request pressure.

Timeout or server failure after a write

Check the run or destination before submitting the write again.

API Versions and Compatibility

Was this helpful?