Warum LLM-Gateways 404 liefern: die /v1-Regel bei Claude Code und OpenAI-SDKs
Führt ein Aufruf über ein eigenes LLM-Gateway zu einem 404-Fehler, liegt das meist nicht an Schlüssel oder Modell, sondern am Pfad-Segment /v1. SDKs von OpenAI und Claude Code erwarten die Endpunkte unterschiedlich, was bei der Konfiguration häufig zu Fehlern führt.

If you've pointed a tool at a custom LLM gateway and got a 404, the cause is usually not your key or the model. It's one path segment: /v1.
I maintain a gateway called HZAPI (public brand HZ AI) and this is the most common support question I see. The rule below is true for any gateway that serves both the Anthropic Messages and OpenAI-compatible APIs.
Why: Anthropic clients treat the Base URL as a root and append /v1/messages themselves, so a trailing /v1 produces /v1/v1/messages. OpenAI clients expect the Base URL to already end in /v1 and append /chat/completions or /responses, so a bare root produces /chat/completions with no version. Both are 404s that look identical.
export HZAPI_API_KEY = "sk-xxxx" # placeholder curl -sS https://api.hzapi.vip/v1/models -H "Authorization: Bearer $HZAPI_API_KEY" Enter fullscreen mode Exit fullscreen mode A 200 with a model array means network, TLS, key and group binding are fine; the problem is in the client. (On HZAPI a key is bound to one group, and the group decides which models you can call. Take model IDs from this call, not from guesswork.)
# Chat Completions curl -sS https://api.hzapi.vip/v1/chat/completions \ -H "Content-Type: application/json" -H "Authorization: Bearer $HZAPI_API_KEY" \ -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"ping"}]}' # Responses curl -sS https://api.hzapi.vip/v1/responses \ -H "Content-Type: application/json" -H "Authorization: Bearer $HZAPI_API_KEY" \ -d '{"model":"gpt-6.2-astra","input":"ping"}' # Anthropic Messages curl -sS https://api.hzapi.vip/v1/messages \ -H "x-api-key: $HZAPI_API_KEY" -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{"model":"claude-fable-5-2","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}' Enter fullscreen mode Exit fullscreen mode (The model IDs above are the examples from the gateway's own guide; availability depends on your key's group and is listed on its model plaza.)
export ANTHROPIC_BASE_URL = "https://api.hzapi.vip" export ANTHROPIC_AUTH_TOKEN = "$HZAPI_API_KEY" claude --model claude-fable-5-2 Enter fullscreen mode Exit fullscreen mode From Claude Code's own docs:
import os from openai import OpenAI client = OpenAI ( api_key = os. environ [ "HZAPI_API_KEY" ], base_url = "https://api.hzapi.vip/v1" ) print ( client. responses. create ( model = "gpt-6.2-astra", input = "One-line summary of idempotent retries" ). output_text ) Enter fullscreen mode Exit fullscreen mode Dify: install the official OpenAI-API-compatible plugin; API Base URL is the /v1 address; Model Name must match an ID from /v1/models exactly; raise the default 4096 context size to the model's real limit.
n8n: in the OpenAI credential change Base URL (default https://api.openai.com/v1 ) to the /v1 address and leave Organization ID empty. The credential test calls {Base URL}/models.
Cherry Studio: add a custom provider with an OpenAI endpoint ( /v1 ) and/or an Anthropic endpoint (root), fetch the model list, add models, and turn the provider's enable switch on.
Cline / Continue: Anthropic mode takes the root; OpenAI-compatible mode takes /v1. Continue defaults to /responses for o-series and gpt-5 models; add useResponsesApi: false if your model doesn't support it.
Cursor: Settings → Models → API Keys → Override OpenAI Base URL = the /v1 address. It's global (affects Cursor's own OpenAI-family models too) and doesn't apply to Tab.
When asking any provider's support for help, send only the last 4 characters of the key, the model name and the time, never the full key.
Runnable minimal samples (Python and Node OpenAI SDKs, curl for all three protocols) plus tutorials for Claude Code, Dify, n8n, Cursor, Cline, Continue and Cherry Studio, in English and Chinese:
https://github.com/Sakcyb/hzapi-examples (MIT, no real keys;.env.example uses sk-xxxx )
Official docs for the gateway: https://hziai.cc/guide/
Disclosure: I maintain HZAPI. The rule in this post applies to any gateway serving both protocol families. I make no claims about pricing or model availability here; see the gateway's model plaza and pricing page.