30[turn errors](#turn-errors) returned after work starts.30[turn errors](#turn-errors) returned after work starts.
31 31
32| Code | Overview |32| Code | Overview |
33| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |33| -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
34| 400: `invalid_request_error` | **Cause:** An input or configuration value is invalid. <br /> **Solution:** Correct the field identified by `error.param` or `error.message`. See [Correct invalid input](#correct-invalid-input). |34| 400: `invalid_request_error` | **Cause:** An input or configuration value is invalid or too large. <br /> **Solution:** Correct the field identified by `error.param` or `error.message`. See [Correct invalid input](#correct-invalid-input). |
35| 400: `invalid_beta` | **Cause:** The `OpenAI-Beta` header contains an invalid value. <br /> **Solution:** Check the header required by the API version you use. |35| 400: `invalid_beta` | **Cause:** The `OpenAI-Beta` header contains an invalid value. <br /> **Solution:** Check the header required by the API version you use. |
36| 400: `agent_not_persisted` | **Cause:** The supplied `agent_id` belongs to a session-local agent. <br /> **Solution:** [Create a saved agent](https://developers.openai.com/api/docs/guides/agents-api/configuration#reuse-an-agent-across-sessions) and use its ID. |36| 400: `agent_not_persisted` | **Cause:** The supplied `agent_id` belongs to a session-local agent. <br /> **Solution:** [Create a saved agent](https://developers.openai.com/api/docs/guides/agents-api/configuration#reuse-an-agent-across-sessions) and use its ID. |
37| 400: `invalid_otlp_endpoint`, `invalid_otlp_header` | **Cause:** The tracing endpoint or headers are invalid. <br /> **Solution:** Correct your [tracing configuration](https://developers.openai.com/api/docs/guides/agents-api/tracing). |37| 400: `invalid_otlp_endpoint`, `invalid_otlp_header` | **Cause:** The tracing endpoint or headers are invalid. <br /> **Solution:** Correct your [tracing configuration](https://developers.openai.com/api/docs/guides/agents-api/tracing). |
38| 401: `unauthorized`; 403: `forbidden` | **Cause:** Authentication failed or the caller lacks access. <br /> **Solution:** Check the API key and its organization, project, and resource permissions. |38| 401: `unauthorized`; 403: `forbidden` | **Cause:** Authentication failed or the caller lacks access. <br /> **Solution:** See the shared [authentication and permission guidance](https://developers.openai.com/api/docs/guides/error-codes#python-library-error-types). |
39| 404: `not_found_error`, `model_not_found` | **Cause:** The resource or model isn't available to this request. <br /> **Solution:** Check the ID, model, project, and whether the resource was deleted. |39| 404: `not_found_error`, `model_not_found` | **Cause:** The resource or model isn't available to this request. <br /> **Solution:** Check the ID, model, project, and whether the resource was deleted. |
40| 409: `conflict_error` | **Cause:** The operation conflicts with the current resource state. <br /> **Solution:** Read the message and retrieve the current state before retrying. |40| 409: `conflict_error` | **Cause:** The operation conflicts with the current resource state. <br /> **Solution:** Read the message and retrieve the current state before retrying. |
41| 409: `executor_version_incompatible` | **Cause:** The executor version isn't supported. <br /> **Solution:** Upgrade the executor, then retry. |41| 409: `executor_version_incompatible` | **Cause:** The executor version isn't supported. <br /> **Solution:** Upgrade the executor, then retry. |
42| 424: `mcp_server_startup_failed` | **Cause:** An MCP server failed to start. <br /> **Solution:** Check the server's configuration and credentials. See [Troubleshoot connections](https://developers.openai.com/api/docs/guides/agents-api/tools/mcp#troubleshoot-connections). |42| 424: `mcp_server_startup_failed` | **Cause:** An MCP server failed to start. <br /> **Solution:** Check the server's configuration and credentials. See [Troubleshoot connections](https://developers.openai.com/api/docs/guides/agents-api/tools/mcp#troubleshoot-connections). |
43| 500: `internal_error` | **Cause:** The service encountered an unexpected error. <br /> **Solution:** [Retry your request](#retry-transient-failures) after a brief wait and contact us if the issue persists. Check the [status page](https://status.openai.com/). |43| 500: `internal_error` | **Cause:** The service encountered an unexpected error. <br /> **Solution:** [Check saved work before retrying](#retry-transient-failures). See the shared [server-error guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
44| 503: `service_unavailable_error`, `server_is_overloaded` | **Cause:** The service or a dependency is temporarily unavailable or overloaded. <br /> **Solution:** Honor `Retry-After` when present, then retry with increasing delays. |44| 503: `service_unavailable_error`, `server_is_overloaded` | **Cause:** The service or a dependency is temporarily unavailable or overloaded. <br /> **Solution:** Follow the shared [503 guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors) and [check saved work before retrying](#retry-transient-failures). |
45 45
46## Turn errors46## Turn errors
47 47
63| `invalid_request` | **Cause:** Input or configuration is invalid. <br /> **Solution:** Correct the input described in the message before trying again. |63| `invalid_request` | **Cause:** Input or configuration is invalid. <br /> **Solution:** Correct the input described in the message before trying again. |
64| `context_length_exceeded` | **Cause:** Input exceeds the model's context window. <br /> **Solution:** Reduce the input. If the conversation is too long, start a new session with a shorter summary. |64| `context_length_exceeded` | **Cause:** Input exceeds the model's context window. <br /> **Solution:** Reduce the input. If the conversation is too long, start a new session with a shorter summary. |
65| `session_budget_exceeded` | **Cause:** The session reached its usage budget. <br /> **Solution:** Start a new session to continue. |65| `session_budget_exceeded` | **Cause:** The session reached its usage budget. <br /> **Solution:** Start a new session to continue. |
66| `credit_balance_exhausted` | **Cause:** The organization has no API credits remaining. <br /> **Solution:** Add credits before retrying. |66| `credit_balance_exhausted` | **Cause:** The organization has no API credits remaining. <br /> **Solution:** See [credit balance guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
67| `project_spend_limit_exceeded` | **Cause:** The project reached its enforced spend limit. <br /> **Solution:** Increase or remove the project's [spend limit](https://developers.openai.com/api/docs/guides/spend-limits). |67| `project_spend_limit_exceeded` | **Cause:** The project reached its enforced spend limit. <br /> **Solution:** See [project spend limit guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
68| `organization_spend_limit_exceeded` | **Cause:** The organization reached its enforced spend limit. <br /> **Solution:** Increase or remove the organization's [spend limit](https://developers.openai.com/api/docs/guides/spend-limits). |68| `organization_spend_limit_exceeded` | **Cause:** The organization reached its enforced spend limit. <br /> **Solution:** See [organization spend limit guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
69| `organization_usage_limit_exceeded` | **Cause:** The organization reached its OpenAI-assigned usage limit. <br /> **Solution:** Request a higher [usage limit](https://developers.openai.com/api/docs/guides/rate-limits#usage-tiers). |69| `organization_usage_limit_exceeded` | **Cause:** The organization reached its OpenAI-assigned usage limit. <br /> **Solution:** See [organization usage limit guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
70| `usage_limit_exceeded` | **Cause:** A billing or usage limit was reached without a more specific code. <br /> **Solution:** Check credits, spend limits, and usage limits before retrying. |70| `usage_limit_exceeded` | **Cause:** A billing or usage limit was reached without a more specific code. <br /> **Solution:** Follow the shared [billing error guidance](https://developers.openai.com/api/docs/guides/error-codes#api-errors). |
71| `rate_limit_exceeded` | **Cause:** Requests exceeded an available rate limit. <br /> **Solution:** Reduce the request rate and [retry with increasing delays](#retry-transient-failures). |71| `rate_limit_exceeded` | **Cause:** Requests exceeded an available rate limit. <br /> **Solution:** Follow the [retry steps](#retry-transient-failures). |
72| `server_overloaded` | **Cause:** The model service is temporarily overloaded. <br /> **Solution:** [Retry the unfinished work after a delay](#retry-transient-failures). If overload persists, [change the model for later turns](https://developers.openai.com/api/docs/guides/agents-api/configuration#update-settings-for-an-existing-session). |72| `server_overloaded` | **Cause:** The model service is temporarily overloaded. <br /> **Solution:** [Retry the unfinished work after a delay](#retry-transient-failures). If overload persists, [change the model for later turns](https://developers.openai.com/api/docs/guides/agents-api/configuration#update-settings-for-an-existing-session). |
73| `flex_unavailable` | **Cause:** Flex processing is temporarily unavailable. <br /> **Solution:** Retry later or [change the session's service tier](https://developers.openai.com/api/docs/guides/agents-api/configuration#update-settings-for-an-existing-session) to standard processing (`default`) for later turns. |73| `flex_unavailable` | **Cause:** Flex processing is temporarily unavailable. <br /> **Solution:** Retry later or [change the session's service tier](https://developers.openai.com/api/docs/guides/agents-api/configuration#update-settings-for-an-existing-session) to standard processing (`default`) for later turns. |
74| `connection_failed`, `request_timeout`, `server_error`, `internal_error` | **Cause:** A connection, timeout, or service failure prevented completion. <br /> **Solution:** Check saved work, then [retry with a limit on attempts](#retry-transient-failures). |74| `connection_failed`, `request_timeout`, `server_error`, `internal_error` | **Cause:** A connection, timeout, or service failure prevented completion. <br /> **Solution:** Check saved work, then [retry with a limit on attempts](#retry-transient-failures). |
75| `authentication_error` | **Cause:** Model access failed because of credentials or permissions. <br /> **Solution:** Check the API key and its organization, project, and model access. |75| `authentication_error` | **Cause:** Model access failed because of credentials or permissions. <br /> **Solution:** See the shared [authentication and permission guidance](https://developers.openai.com/api/docs/guides/error-codes#python-library-error-types). |
76| `resource_not_found` | **Cause:** The requested model or resource is unavailable. <br /> **Solution:** Check the model and session configuration before retrying. |76| `resource_not_found` | **Cause:** The requested model or resource is unavailable. <br /> **Solution:** Check the model and session configuration before retrying. |
77| `sandbox_error` | **Cause:** The environment couldn't complete an operation. <br /> **Solution:** Inspect the environment error and fix its configuration or connectivity. |77| `sandbox_error` | **Cause:** The environment couldn't complete an operation. <br /> **Solution:** Inspect the environment error and fix its configuration or connectivity. |
78| `executor_version_incompatible` | **Cause:** The executor can't run this turn. <br /> **Solution:** Upgrade the executor, then retry on the same session if it hasn't failed. |78| `executor_version_incompatible` | **Cause:** The executor can't run this turn. <br /> **Solution:** Upgrade the executor, then retry on the same session if it hasn't failed. |
79| `active_turn_not_steerable` | **Cause:** The active turn can't accept more input. <br /> **Solution:** Wait for it to finish before sending another message. |79| `active_turn_not_steerable` | **Cause:** The active turn can't accept more input. <br /> **Solution:** Wait for it to finish before sending another message. |
80| `cyber_policy`, `misalignment_policy_violation` | **Cause:** Safety systems blocked the request. <br /> **Solution:** Review the request against the applicable safety requirements before submitting revised input. |80| `cyber_policy`, `misalignment_policy_violation` | **Cause:** Safety systems blocked the request. <br /> **Solution:** Review the request against the applicable safety requirements before submitting revised input. |
81 81
82Billing errors need a billing action, not a faster retry loop. A generic
83`usage_limit_exceeded` can still occur when a more specific cause isn't available.
84
85## Session and environment errors82## Session and environment errors
86 83
87A failed turn doesn't always mean the session has failed. Retrieve the session to84A failed turn doesn't always mean the session has failed. Retrieve the session to
107 104
1081. **Check the outcome.** If a session was created, retrieve it, the turn, and [saved items](https://developers.openai.com/api/docs/guides/agents-api/sessions/events#fetch-items-and-turns). If the turn is still active, keep following it. If it completed, use its result.1051. **Check the outcome.** If a session was created, retrieve it, the turn, and [saved items](https://developers.openai.com/api/docs/guides/agents-api/sessions/events#fetch-items-and-turns). If the turn is still active, keep following it. If it completed, use its result.
1092. **Check completed actions.** A failed turn may already have changed files or called external tools. Confirm those effects before asking the agent to repeat work.1062. **Check completed actions.** A failed turn may already have changed files or called external tools. Confirm those effects before asking the agent to repeat work.
1103. **Wait and limit retries.** Honor `Retry-After` when an HTTP response includes it. Otherwise, use [exponential backoff with jitter](https://developers.openai.com/api/docs/guides/rate-limits#retrying-with-exponential-backoff): increase the delay between attempts and add a small random delay. Set an attempt limit or deadline.1073. **Wait and limit retries.** Follow the shared [retry guidance](https://developers.openai.com/api/docs/guides/rate-limits#retrying-with-exponential-backoff), honoring `Retry-After` on HTTP responses and setting an attempt limit or deadline.
1114. **Retry the request or start a new turn.** For an HTTP error, retry the original operation after checking its outcome. For a failed turn, wait until the session is `idle`, then [send a follow-up message](https://developers.openai.com/api/docs/guides/agents-api/sessions#continue-or-steer-the-work) asking it to continue only unfinished work. This starts a new turn with the existing conversation.1084. **Retry the request or start a new turn.** For an HTTP error, retry the original operation after checking its outcome. For a failed turn, wait until the session is `idle`, then [send a follow-up message](https://developers.openai.com/api/docs/guides/agents-api/sessions#continue-or-steer-the-work) asking it to continue only unfinished work. This starts a new turn with the existing conversation.
112 109
113Inspect tool results even when a turn completes. Stop automatic retries if the error changes or the110Inspect tool results even when a turn completes. Stop automatic retries if the error changes or the
116### Correct invalid input113### Correct invalid input
117 114
118Correct the field identified by `error.param` or `error.message` before resubmitting.115Correct the field identified by `error.param` or `error.message` before resubmitting.
116
117For size errors, reduce the [input and output schema](https://developers.openai.com/api/docs/guides/agents-api/sessions#input-size)
118or [tool result](https://developers.openai.com/api/docs/guides/agents-api/tools/functions) before retrying.
119If the [agent configuration](https://developers.openai.com/api/docs/guides/agents-api/configuration) is too large,
120create a new session with smaller instructions and tool definitions.
121
119For upload requirements and examples, see [Resolve upload errors](https://developers.openai.com/api/docs/guides/agents-api/environments/files#resolve-upload-errors).122For upload requirements and examples, see [Resolve upload errors](https://developers.openai.com/api/docs/guides/agents-api/environments/files#resolve-upload-errors).
120If the message identifies an image problem, check the image data or URL.123If the message identifies an image problem, check the image data or URL.
121 124
124An `error` event or a disconnected stream doesn't confirm the turn's final state.127An `error` event or a disconnected stream doesn't confirm the turn's final state.
125Follow [Recover a disconnected stream](https://developers.openai.com/api/docs/guides/agents-api/sessions/events#how-to-recover-a-disconnected-stream)128Follow [Recover a disconnected stream](https://developers.openai.com/api/docs/guides/agents-api/sessions/events#how-to-recover-a-disconnected-stream)
126to reconnect and check saved work before resubmitting input.129to reconnect and check saved work before resubmitting input.
130If the retrieved session has `status: "failed"` or you receive `agent.session.failed`,
131stop reconnecting and follow the
132[session recovery guidance](#session-and-environment-errors).
127 133
128If failures persist, keep the request ID, session ID, turn ID, error code, and134For [persistent errors](https://developers.openai.com/api/docs/guides/error-codes#persistent-errors), include
129time of the failure for support.135the request ID, session ID, and turn ID with your support request.