Home → Help
SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSONjson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)invalid character '<' looking for beginning of valueError: Invalid JSON response bodyMost OpenAI-compatible gateways serve their website and their API from the same domain. When you request a path the API does not recognise, you do not get a clean 404 — you get the site's front-end, with HTTP 200 and Content-Type: text/html.
From the client's point of view everything succeeded, so it goes ahead and parses the body. The error you see is a JSON parser complaining about the first character of an HTML document, which points nowhere near the real problem.
This also means the failed call usually leaves no trace in the provider's error logs — a 200 is not an error. Support will tell you they see nothing wrong, and they are being truthful.
Confirm it in one command. Send a request and look at the content type rather than the body:
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' \
-X POST 'YOUR_BASE_URL/chat/completions' \
-H 'Authorization: Bearer YOUR_KEY' \
-H 'Content-Type: application/json' \
-d '{"model":"MODEL","messages":[{"role":"user","content":"hi"}]}'
A working endpoint returns application/json — even when the key is wrong, you get JSON saying so. If you see text/html, the URL is the problem, not the key.
| Client | Base URL should be |
|---|---|
| OpenAI SDK (Python, Node, Go) | ends with /v1 |
| Codex, Cherry Studio, Chatbox, LobeChat | ends with /v1 |
| Anthropic SDK | no /v1 — it appends /v1/messages |
| Claude Code | no /v1 — same reason |
https://apiclan.us/v1 for OpenAI-style clients and https://apiclan.us for Claude Code. Full setup for every client is in the quickstart.Last checked 2026-08-24. Written from problems diagnosed on a live OpenAI-compatible gateway, not collected from other sites.