Home → Help

404 on /v1/chat/completions when the endpoint clearly exists

Check the HTTP method first. /v1/chat/completions only answers POST — a GET returns 404 by design, on essentially every OpenAI-compatible gateway.

What you are seeing

Why it happens

This catches people out during debugging more than in production. You paste the URL into a browser, or into a tool that defaults to GET, see a 404, and conclude the endpoint is down. The endpoint is fine; it simply has no GET handler.

It is easy to verify: a path that genuinely does not exist and a path that exists but rejects your method both return 404, but only one of them changes behaviour when you switch to POST.

Confirm it is this

Send the same path twice, once each way, and compare:

# GET — expect 404 even on a healthy endpoint
curl -s -o /dev/null -w 'GET  %{http_code}\n' \
  'YOUR_BASE_URL/chat/completions'

# POST with a deliberately bad key — expect 401
curl -s -o /dev/null -w 'POST %{http_code}\n' -X POST \
  'YOUR_BASE_URL/chat/completions' \
  -H 'Authorization: Bearer invalid' \
  -H 'Content-Type: application/json' -d '{}'

GET 404 followed by POST 401 means the endpoint is healthy and you were testing it the wrong way. Two 404s means the path really is wrong.

How to fix it

  1. Use POSTChat completions, messages and embeddings are all POST endpoints. Only listing endpoints such as /v1/models answer GET.
  2. Count the path segmentsThe full path is /v1/chat/completions. Missing the /v1, or doubling it because your client adds it too, both land on paths that do not exist.
  3. Check for a proxy rewriting your pathCorporate proxies and API gateways sometimes strip or add a prefix. Compare the URL your client logs against the one the server reports receiving.
APICLAN behaves the same way: GET /v1/chat/completions returns 404 and POST returns a JSON error until you supply a valid key. Endpoints and examples are in the quickstart.

Related

Unexpected token '<' when calling an OpenAI-compatible API401 invalid API key — when the key looks right but still fails

Last checked 2026-08-24. Written from problems diagnosed on a live OpenAI-compatible gateway, not collected from other sites.