Learn Build Community Opportunities Hosted n8n Blog About Careers Contact Log in

Home / Blog / Fix

Fix

Fix OpenAI http 520 post v1 responses errors

If POST /v1/responses returns persistent HTTP 520 Cloudflare errors when using Sign in with ChatGPT tokens, follow this checklist to reproduce, diagnose headers and tokens, and apply reliable workarounds.

If you see openai http 520 post v1 responses errors when calling the Responses endpoint with Sign in with ChatGPT OAuth tokens, this is usually Cloudflare rejecting the request based on token type, missing headers or egress IP issues. Use the checklist below to reproduce, inspect headers and swap to a valid API key or proxy as a fast workaround.

Why this happens (short)

HTTP 520 is a Cloudflare generic error returned when the edge cannot get a valid response from the origin, or when Cloudflare actively blocks a request. For OpenAI, common causes are using non-API tokens intended for browser sign-in, missing or unusual request headers, or egress IP addresses that trigger Cloudflare security rules.

openai http 520 post v1 responses: reproducible minimal requests

First reproduce the failure with the smallest possible request. This proves the problem is transport/security, not payload or model content. Use a curl POST to https://api.openai.com/v1/responses with the same token your integration uses.

curl -v -X POST https://api.openai.com/v1/responses \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"gpt-4o-mini","input":"Hello"}'

If the curl run returns a Cloudflare 520 or a short HTML error page, note the full verbose output including response headers. That proves the issue is not an SDK or platform wrapper.

Step-by-step troubleshooting checklist (ol)

  1. Reproduce with curl as above and save full verbose output, including response headers.
  2. Check the token type and scope. If you are using a Sign in with ChatGPT OAuth token, try an official API key from your OpenAI dashboard. Sign-in tokens are often rejected by API endpoints, causing 520 or 403 style blocks.
  3. Inspect headers. Required headers include Authorization: Bearer <token> and Content-Type: application/json. Add a sane User-Agent string where possible. Avoid unusual or empty UA values that can trigger WAF rules.
  4. Examine response headers for Cloudflare clues. Look for headers like cf-ray or any HTML error body that references Cloudflare. Copy the cf-ray value if present for support tickets.
  5. Test from a different egress IP or network. If curl from your server fails but your laptop on a mobile network works, this indicates IP reputation or firewall problems with Cloudflare.
  6. Retry with exponential backoff for transient 5xx errors. Implement a retry loop with backoffs of 1s, 2s, 4s and stop after 5 tries. Record timestamps for support if problem persists.
  7. If all else fails, switch to a proper API key and stable egress IP or use a trusted proxy with static IP while you investigate long term fixes.

Header and token checks developers miss

Many forum replies miss simple header and token issues. Verify these:

  • Token source - Tokens obtained via "Sign in with ChatGPT" are intended for browser sessions. For server-to-API calls, use an API key from your OpenAI dashboard. If you must use an OAuth flow, ensure it is an API-specific OAuth client and grant scopes that cover the Responses API.
  • Authorization format - Use Authorization: Bearer <token>. Leading or trailing spaces cause rejection.
  • Content-Type - Set application/json for JSON bodies.
  • User-Agent - Some WAF rules treat empty or tool-specific UAs as risky. Set a clear UA like MyApp/1.0 (+https://example.com).
  • Payload size - Very large bodies can be dropped by edge proxies. Try a tiny payload to confirm.

Cloudflare related causes and signals

When Cloudflare is involved you may see these signals:

  • HTML response body referencing Cloudflare, or a header cf-ray.
  • Requests that succeed from consumer IPs but fail from cloud host IPs, indicating IP reputation rules.
  • Intermittent 520 spikes, often correlated with traffic bursts or a change in your egress IP.

Record the exact time, the originating IP, and the cf-ray header value and include them if contacting OpenAI support. A forum thread discussing this issue can provide context: OpenAI dev forum thread on persistent HTTP 520.

Reliable workarounds people miss

Forum replies often suggest generic retries. Use these reliable fixes instead.

  • Use an official API key from your OpenAI dashboard for server calls. This is the fastest way to eliminate the token-type mismatch.
  • Proxy or egress fix - Route requests through a stable proxy with a reputable static IP. Many cloud firewalls or hosting providers change outbound IPs, which can trigger Cloudflare rules.
  • Retry with exponential backoff - For transient 5xx responses, implement backoff 1s, 2s, 4s, 8s, with jitter. Stop after 5 attempts and log details.
  • Temporary token pattern - If your flow must use user tokens, obtain a server-side API key or use server-controlled tokens that you rotate, rather than browser-only sign-in tokens. Avoid sending session cookies or browser tokens to the API endpoint.

Tool specific notes: n8n, Make.com and Zapier

n8n

  • Use the HTTP Request node to call https://api.openai.com/v1/responses. Set Method to POST, add the Authorization and Content-Type headers, and a small JSON body to test. For retry, build a loop with a Wait node and conditional IF nodes to retry on 5xx.
  • If using OAuth credentials in n8n, prefer a stored API key credential and see our post on production-ready refresh patterns if you must rotate tokens: N8n oauth2 refresh token: production-ready refresh pattern.

Make.com

  • Use the HTTP module in a scenario. Keep the request minimal for testing. Add an error handler route and enable repeating runs with sleep modules for backoff.

Zapier

  • Use Webhooks by Zapier with POST. Add a Code step to implement exponential backoff if the webhook returns HTTP 520. Prefer a server API key instead of browser OAuth tokens.

How to stop it happening again

  1. Use official API keys for server-to-server calls and rotate them securely.
  2. Normalize headers, including a clear User-Agent and Content-Type: application/json.
  3. Stabilize egress IPs or use a trusted proxy with a static IP address so Cloudflare reputation is stable.
  4. Monitor and log full request/response details including timestamps and cf-ray. Alert on repeated 5xx patterns and roll out fallbacks.

When to get help

If you have reproduced a 520 from multiple networks, and a switch to a proper API key does not fix it, open a support ticket with OpenAI and include:

  • Verbose curl output and request headers
  • Response body and cf-ray header if present
  • Timestamps and originating egress IPs

Also review community posts for similar reports, such as the discussion about model and response errors: Model Not Found on ChatGPT thread. These threads can help validate whether the issue is widespread.

If you want hands-on help converting a failing workflow into a robust automation in n8n, Make.com or Zapier, learn to build automations like this with Automate Naija.

Frequently asked questions

Why do I get HTTP 520 when calling POST /v1/responses?

HTTP 520 is a Cloudflare edge error. Common causes are using browser Sign in with ChatGPT tokens instead of server API keys, missing headers like Content-Type, unusual User-Agent values, or egress IP reputation issues. Reproduce with curl and check response headers for Cloudflare clues.

Can I fix post v1 responses 520 by retrying?

Retries help only for transient 5xx spikes. Implement exponential backoff with jitter (for example 1s, 2s, 4s) and stop after several attempts. If the error is caused by token type or IP reputation, retries will not fix the root cause.

Are Sign in with ChatGPT OAuth tokens supported for server API calls?

Tokens from Sign in with ChatGPT are intended for browser sessions and can be blocked when calling server API endpoints. For reliable server-to-server calls, use an official API key from your OpenAI dashboard or a server-side token explicitly issued for API access.

What info should I include when contacting OpenAI about a 520?

Include verbose curl output, request headers (with Authorization masked), the response body, any Cloudflare headers such as cf-ray, timestamps and the originating egress IP. This helps OpenAI and Cloudflare investigate edge-level blocks.


Build it with us. The community is free and the build track teaches this kind of automation week by week: see pricing or join the community.

Keep reading

A new fix lands here every morning, picked from what builders are stuck on right now.