Resource

Common OpenAI Errors

A practical troubleshooting guide for OpenAI API authentication, billing and quota issues, rate limits, malformed requests, permissions, timeouts, cURL and SSL failures, and temporary provider-side errors.

Common OpenAI API Errors and How to Troubleshoot Them

When an AI-powered application fails, the fastest path to a fix is to identify which layer is actually failing. An OpenAI error can come from the API account, the API request, your hosting environment, your application configuration, or a temporary service problem.

Do not start by changing random settings. Capture the exact error message first, then work through the appropriate checks.

A Good Troubleshooting Order

  1. Record the exact error message and when it occurred.
  2. Confirm the OpenAI API key is present and current.
  3. Check the API account's billing, usage, project, and access status.
  4. Confirm your server can make outbound HTTPS requests.
  5. Check the application's PHP/server error log.
  6. Determine whether the error is consistent or only temporary.
Important: ChatGPT subscriptions and OpenAI API billing are separate. A working ChatGPT account does not by itself confirm that a separate API application has usable API billing or access.

Authentication / Invalid API Key Errors

Authentication errors mean the API could not accept the credential that was supplied.

Common Causes

  • The key was copied incorrectly.
  • Part of the key is missing.
  • An extra space or line break was saved with the key.
  • The key was revoked or deleted.
  • The wrong application's key is being used.
  • A placeholder value was saved instead of a real credential.

What to Do

  1. Open your application's settings and re-enter the key carefully.
  2. Do not try to reconstruct a secret key from a partially displayed value.
  3. If you are uncertain whether the key is valid, create a new credential and update the application.
  4. Test again with a small request.

Billing, Quota, or Usage-Limit Errors

These errors indicate that the API account or project is not currently able to process the requested usage under its billing or usage configuration.

What to Check

  • API billing is configured.
  • The account or project is active.
  • Any applicable budget, balance, credit, or usage restriction has not been reached.
  • You are reviewing the developer/API billing area rather than only your ChatGPT subscription.

Provider terminology and billing controls can change over time, so use the current OpenAI dashboard as the source of truth for your account.

Rate Limit / 429-Type Errors

A rate-limit response does not always mean the application is "broken." APIs place limits on how much work an account or project can request within particular time windows or usage tiers.

Possible Causes

  • Too many requests were sent in a short period.
  • Requests are too large for an applicable throughput limit.
  • A retry loop is sending the same failing request repeatedly.
  • The account or project has reached an applicable usage restriction.

What to Do

  • Reduce unnecessary repeat requests.
  • Allow appropriate time between retries.
  • Avoid unlimited automatic retry loops.
  • Review current API limits and usage in your OpenAI account.
  • Reduce unnecessary prompt or output size when throughput is the issue.

400 / Bad Request Errors

A bad-request error generally means the API received the request but could not process it in the form submitted.

Possible Causes

  • A required request value is missing.
  • A parameter value is invalid.
  • The selected model or endpoint does not accept the request configuration.
  • The input exceeds an applicable request or context limit.
  • Structured data sent to the API is malformed.

If you are using an unmodified AI PHP Apps product and this suddenly begins occurring, preserve the full error and check whether anything changed in the application's settings, model configuration, or provider requirements.

401 Errors

A 401 response usually points to authentication. Start with the API key and credential configuration.

403 Errors

A 403 response generally means the request was understood but the account, project, credential, or resource does not have permission to perform it.

Check project membership, key permissions, model/resource access, and any account restrictions shown in the provider dashboard.

429 Errors

429 responses are commonly associated with rate or usage limits. Read the accompanying API message because it can provide more specific information than the HTTP status number alone.

500, 502, and 503 Errors

Server-side errors can be temporary and may originate upstream rather than in your PHP application.

If the same request normally works and suddenly returns a 5xx error:

  • Try again after a reasonable interval.
  • Check the provider's current service status.
  • Do not create an aggressive retry loop.
  • Record whether the failure affects every request or only one particular input.

Connection Errors

If PHP cannot connect to the API at all, the issue may be between your hosting server and the remote HTTPS service.

Check:

  • Outbound HTTPS connections are allowed by your host.
  • PHP cURL is installed and enabled when the application relies on it.
  • DNS resolution is working on the server.
  • The server's certificate authorities are current.
  • A hosting firewall is not blocking the connection.

cURL Errors

A cURL error is often a hosting or network clue rather than an OpenAI account problem.

Common categories include:

  • DNS lookup failures
  • Connection timeouts
  • SSL certificate verification failures
  • Blocked outbound connections
  • Connection resets

Keep the cURL error number and complete message. Your hosting provider can often diagnose a server-network issue much faster when you provide those details.

SSL Certificate Errors

Do not solve SSL verification errors by permanently disabling certificate verification. That removes an important security check.

Instead, confirm that the server's SSL/certificate environment is current and correctly configured. On managed or shared hosting, contact the hosting provider if the server cannot validate a legitimate remote HTTPS certificate.

Timeout Errors

A timeout can occur at more than one layer:

  • The remote API request may take longer than expected.
  • PHP's maximum execution time may be too low for the workload.
  • A proxy, firewall, or web server may impose its own timeout.
  • The request may contain substantially more input than normal.

Before increasing server limits indefinitely, determine why the request is taking so long. A shorter or better-scoped request may be a more reliable solution.

Model or Configuration Errors

If an application allows model selection, confirm that the configured model is still available to the API account and appropriate for the request type supported by the application.

A model name copied from an old tutorial or another product may not be valid for your current API configuration.

Errors That Only Affect One Input

If most requests work but one particular request fails, compare that input with successful requests.

Look for:

  • Extremely large pasted text
  • Unusual characters or malformed structured data
  • A file or record that is much larger than normal
  • Missing required application fields

Errors That Affect Every Request

If every request fails, start with system-wide dependencies:

  1. API key
  2. API billing/account status
  3. Application model/configuration
  4. Outbound server connectivity
  5. Hosting or PHP changes

Check Your PHP Error Log

The message displayed in the browser may be intentionally simplified. Your PHP or application error log can contain the detail needed to separate an API error from an internal application error.

Do not enable public display of sensitive production errors simply to troubleshoot. Prefer server-side logs.

Information to Collect Before Asking for Help

  • The exact error message
  • The date and approximate time it happened
  • The application page or action involved
  • Whether the problem affects every request
  • Whether anything recently changed
  • Relevant PHP/application log entries with secrets removed
Never include: your API key, database password, hosting password, or other secret credentials in a public support request.

Quick Diagnostic Checklist

  • API key is complete and current
  • API billing/account status is valid
  • Configured model/resource is appropriate
  • Server can make outbound HTTPS requests
  • PHP cURL and SSL support are working
  • Request is not unusually large
  • No uncontrolled retry loop is running
  • PHP/server logs have been checked
  • Temporary provider status has been considered

Next Step

If your API works but you are unsure which model best fits a particular business task, continue with Choosing an AI Model.

Need more help?

If you have questions about setting up an AI PHP Apps product, contact support and we’ll help point you in the right direction.

Contact Support