Every "connect your agent to a custom endpoint" guide I have read stops at the same place: it shows a config block and says done. Then the request fails with a 400, and you spend an evening guessing which field the tool actually sends.
This post is the field list, agent by agent, plus the four request-shape mismatches that cause almost every failure. It is written from the gateway side — I work on the docs for NovaAPI, an independent OpenAI/Anthropic-compatible gateway — so the failures here are the ones that reach support, not hypothetical ones.
First: three values, and only three
Whatever the tool, you are filling in the same three things.
| Value | What it looks like |
|---|---|
| Base URL (OpenAI format) | https://api.lbase.com/v1 |
| Base URL (Anthropic format) |
https://api.lbase.com — the client appends /v1/messages
|
| Model name |
deepseek-flash, deepseek-v4-pro
|
| API key |
sk-..., scoped to a group in the console |
The subtlety is that "base URL" is not one thing. Anthropic-style clients want the host; OpenAI-style clients want the host plus /v1; a few clients append /v1 themselves and will produce /v1/v1/chat/completions if you paste the wrong form. When a 404 looks like a routing problem, it is almost always this.
The field map
| Agent | Protocol it speaks | Where the values go |
|---|---|---|
| DeepSeek Harness | OpenAI Chat Completions | Settings → Models → Add model provider → Custom model API |
| Claude Code | Anthropic Messages |
~/.claude/settings.json or ANTHROPIC_* env vars |
| Codex CLI | OpenAI Responses |
~/.codex/config.toml, [model_providers.*]
|
| OpenCode | OpenAI Chat Completions |
opencode.json, providers block (v2) |
| Hermes Agent | OpenAI Chat Completions |
~/.hermes/config.yaml + key in ~/.hermes/.env
|
| Cline | OpenAI Chat Completions | Provider = "OpenAI Compatible" |
| Cursor | OpenAI Chat Completions | Settings → Models → override base URL |
| Dify | OpenAI Chat Completions | Model Provider → "OpenAI-API-compatible" |
| n8n | OpenAI Chat Completions | OpenAI credential, base URL field |
Nine tools, three protocols. Everything below is a variation on that sentence.
Failure 1: the developer role
Newer OpenAI SDKs and several agents send role: "developer" instead of role: "system". Some gateways and backends reject it with a 400 that does not mention the role.
If you control the client, map developer to system. If you do not — DeepSeek Harness is the common case — most gateways expose a compatibility switch. In Harness that lives in $DSH_HOME/profiles/web/cordis.patch.yml:
- id: llm-pi-ai
config:
providers:
novaapi:
api: openai-completions
baseURL: https://api.lbase.com/v1
apiKeyEnv: NOVAAPI_API_KEY
compat:
supportsDeveloperRole: false
maxTokensField: max_tokens
models:
- id: deepseek-flash
- id: deepseek-v4-pro
Keep the key in the environment, not in that file. The UI path (Settings → Models → Add model provider → Custom model API, protocol "OpenAI Chat Completions") does the same thing and is enough for most people; the YAML is for when the request shape needs tuning.
Failure 2: max_tokens vs max_completion_tokens
The same class of problem, different field. Clients that migrated to the newer parameter send max_completion_tokens; backends that only know max_tokens reject the whole request. maxTokensField: max_tokens in the block above is the fix for Harness; for your own code, send max_tokens unless you have confirmed the other side accepts both.
Failure 3: Codex only speaks Responses
This one surprises people because the config looks fine. Codex CLI's wire_api currently supports responses and defaults to it — Chat Completions is not an option. So the provider must expose /v1/responses, not only /v1/chat/completions.
model = "deepseek-flash"
model_provider = "novaapi"
review_model = "deepseek-flash"
disable_response_storage = true
[model_providers.novaapi]
name = "NovaAPI"
base_url = "https://api.lbase.com/v1"
env_key = "NOVAAPI_API_KEY"
wire_api = "responses"
requires_openai_auth = false
Put the key in NOVAAPI_API_KEY, not in the TOML. Project-level config files do not override the provider — use the user-level file.
Failure 4: OpenCode v1 config in a v2 install
OpenCode's config shape changed. The old form used provider / npm / options; v2 uses providers with a package and settings. Pasting a v1 snippet into v2 gives you a config that loads and then quietly has no models.
{
"$schema": "https://opencode.ai/config.json",
"model": "novaapi/deepseek-flash",
"providers": {
"novaapi": {
"name": "NovaAPI",
"env": ["NOVAAPI_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": { "baseURL": "https://api.lbase.com/v1" },
"models": {
"deepseek-flash": { "name": "DeepSeek V4.1 Flash" },
"deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
}
}
}
}
Then /models and pick novaapi/deepseek-flash. /reload applies it; no restart.
Claude Code is the one that wants the host, not /v1
With Anthropic-format clients the base URL is the host only:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-your-key-here",
"ANTHROPIC_BASE_URL": "https://api.lbase.com",
"ANTHROPIC_MODEL": "deepseek-flash"
}
}
If you also want to keep your existing Claude model names, create the key in a Claude-compatible group instead and leave the model name alone — the alias routes to the same backend.
Verify with curl before you debug the agent
This is the step that saves the evening. One request, outside the agent:
curl https://api.lbase.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-flash","messages":[{"role":"user","content":"Hello!"}]}'
- It works, the agent does not → the problem is in the agent's field mapping, not the key. Check the four failures above.
- 401 → key wrong, revoked, or created without a group.
- 402 → balance exhausted.
-
404 → model name not available to that key's group, or a doubled
/v1in the base URL. -
400/422 → request shape:
developerrole,max_completion_tokens, or a tool-calling schema the backend does not accept.
Key hygiene that is not optional
One key per agent or per machine, so a leaked key can be revoked without breaking everything else. Keys are shown once. Do not commit .env, do not put the literal key in config.toml or YAML, and rotate anything you have pasted into a screenshot, a chat, or an issue.
If you are wiring one of the nine and the field names do not match what you see in the UI, the per-agent pages with the exact strings are here: Connect your agent to NovaAPI — that page is the canonical version of this post. Account mechanics (credit, minimum top-up, model list, billing) are in the docs, and if a payment is failing rather than a request, start with the payment help hub.
Top comments (0)