litellm - 💡(How to fix) Fix [Bug]: Cannot use ChatGPT subscription sucessfully [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#27175Fetched 2026-05-06 06:15:44
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Error Message

07:33:17 - LiteLLM:DEBUG: main.py:7283 - openai.py: Received openai error - <html> ... </html> ... <span id="challenge-error-text">Enable JavaScript and cookies to continue</span> ...

Fix Action

Fix / Workaround

Important instrumentation finding

We instrumented the outbound HTTP request from LiteLLM (monkey-patched httpx.Client.send) and observed:

  • Method/URL: POST https://chatgpt.com/backend-api/codex/chat/completions
  • Headers include Authorization + User-Agent
  • No Cookie header present

Code Example

07:33:09 - LiteLLM:INFO: utils.py:4011 -
LiteLLM completion() model= gpt-5.4-mini; provider = chatgpt

07:33:09 - LiteLLM:DEBUG: litellm_logging.py:1166 -
POST Request Sent from LiteLLM:
curl -X POST \
https://chatgpt.com/backend-api/codex/ \
-d '{'model': 'gpt-5.4-mini', 'messages': [{'role': 'user', 'content': 'Reply exactly: hello'}], 'extra_body': {}}'

07:33:17 - LiteLLM:DEBUG: main.py:7283 - openai.py: Received openai error - <html> ... </html>
... <span id="challenge-error-text">Enable JavaScript and cookies to continue</span> ...
... /backend-api/codex/chat/completions?__cf_chl_... ...
07:33:18 - LiteLLM:DEBUG: litellm_logging.py:2934 - Logging Details LiteLLM-Failure Call: []



Text from call:
HTTPX_SEND POST https://chatgpt.com/backend-api/codex/chat/completions
HEADER_KEYS accept,accept-encoding,authorization,connection,content-length,content-type,host,user-agent,x-stainless-arch,x-stainless-async,x-stainless-lang,x-stainless-os,x-stainless-package-version,x-stainless-raw-response,x-stainless-read-timeout,x-stainless-retry-count,x-stainless-runtime,x-stainless-runtime-version
AUTH_SCHEME Bearer
HAS_COOKIE no
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

--- Short Version: --- Confirming this issue with reproducible data.

  • LiteLLM 1.83.14, chatgpt/* OAuth device flow
  • Requests to https://chatgpt.com/backend-api/codex/chat/completions return Cloudflare challenge HTML / 403
  • Reproduced from two different hosts with same egress IP (so not a single-host routing issue)

Key debug finding:

  • LiteLLM outbound request includes Authorization + User-Agent
  • No Cookie header present
  • Challenge HTML is returned instead of JSON

So valid OAuth token alone is not sufficient in this environment for this endpoint path. This appears to be a ChatGPT-provider compatibility gap in LiteLLM under Cloudflare challenge conditions.

--- Longer Version: --- We can reproduce this consistently in a dual-host setup and can confirm it is not just a single-host network anomaly.

Environment

  • LiteLLM: 1.83.14
  • Provider path: chatgpt/* (ChatGPT subscription OAuth device flow)

Reproduction summary

  1. OAuth auth file is present and valid (access_token, refresh_token, id_token, non-expired expires_at).
  2. LiteLLM service is healthy and listening.
  3. Calling chatgpt/gpt-5.4-mini through LiteLLM returns Cloudflare challenge HTML (not JSON) and surfaces as 403/APIError.
  4. Direct probes from both hosts to the same Codex endpoint with bearer auth show same behavior class (challenge/blocked response), so this is not host-specific routing.

Important instrumentation finding

We instrumented the outbound HTTP request from LiteLLM (monkey-patched httpx.Client.send) and observed:

  • Method/URL: POST https://chatgpt.com/backend-api/codex/chat/completions
  • Headers include Authorization + User-Agent
  • No Cookie header present

Given the response is Cloudflare challenge HTML, this looks like bearer-only request context being insufficient for this edge policy in some environments.

Related behavior observed

  • Separate from 403: some chatgpt/gpt-5.4 flows still exhibit output=[] / Unknown items in responses API response: [] patterns (likely related to #25429/#26179 lineage).
  • But for this issue specifically, current blocker is Cloudflare challenge on /backend-api/codex/chat/completions.

If useful, we can share sanitized debug logs showing:

  • exact outbound URL/header keys
  • challenge HTML signature
  • dual-host parity checks (same egress/traceroute pattern)

Steps to Reproduce

Relevant log output

07:33:09 - LiteLLM:INFO: utils.py:4011 -
LiteLLM completion() model= gpt-5.4-mini; provider = chatgpt

07:33:09 - LiteLLM:DEBUG: litellm_logging.py:1166 -
POST Request Sent from LiteLLM:
curl -X POST \
https://chatgpt.com/backend-api/codex/ \
-d '{'model': 'gpt-5.4-mini', 'messages': [{'role': 'user', 'content': 'Reply exactly: hello'}], 'extra_body': {}}'

07:33:17 - LiteLLM:DEBUG: main.py:7283 - openai.py: Received openai error - <html> ... </html>
... <span id="challenge-error-text">Enable JavaScript and cookies to continue</span> ...
... /backend-api/codex/chat/completions?__cf_chl_... ...
07:33:18 - LiteLLM:DEBUG: litellm_logging.py:2934 - Logging Details LiteLLM-Failure Call: []



Text from call:
HTTPX_SEND POST https://chatgpt.com/backend-api/codex/chat/completions
HEADER_KEYS accept,accept-encoding,authorization,connection,content-length,content-type,host,user-agent,x-stainless-arch,x-stainless-async,x-stainless-lang,x-stainless-os,x-stainless-package-version,x-stainless-raw-response,x-stainless-read-timeout,x-stainless-retry-count,x-stainless-runtime,x-stainless-runtime-version
AUTH_SCHEME Bearer
HAS_COOKIE no

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.83.14

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The issue can be resolved by adding a Cookie header to the outbound HTTP request from LiteLLM, as the current bearer-only request context is insufficient for the Cloudflare challenge.

Guidance

  • Verify that the issue is indeed caused by the missing Cookie header by checking the request headers in the debug logs.
  • Attempt to add a Cookie header to the request, potentially by modifying the httpx.Client.send method or by configuring LiteLLM to include cookies in the request.
  • Investigate the specific requirements for the Cookie header, such as the necessary cookie names and values, to ensure that the request is properly formatted.
  • Consider reaching out to the ChatGPT provider for guidance on how to properly handle the Cloudflare challenge and ensure compatibility with LiteLLM.

Example

No code example is provided, as the necessary modifications would depend on the specific implementation details of LiteLLM and the httpx library.

Notes

The solution may require additional modifications to handle the Cloudflare challenge correctly, such as enabling JavaScript or modifying the request headers to include the necessary cookies.

Recommendation

Apply a workaround by adding a Cookie header to the outbound HTTP request, as this is likely to resolve the issue and allow LiteLLM to properly handle the Cloudflare challenge.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: Cannot use ChatGPT subscription sucessfully [1 participants]