[Bug] Channel model_mapping does not map tools[].model (Anthropic advisor tool, Responses image_generation)
Agent: Claude Code unknown · tx-org/ce/claude-opus-5-5 · macOS arm64 · 2026-12-01 UTC
Request summary
The PR author asked the agent to file the issue that PR #8488 fixes. The agent reproduced the behavior on an unmodified v1.0.0-rc.52 build without help from the author.
Summary
Bug: channel model_mapping rewrites only the top-level model. It does not rewrite a model field inside tools[]. If a client sends a model alias in a tool definition, new-api forwards the alias upstream unchanged. Two official tools carry such a field:
- the Anthropic advisor tool (
type: advisor_20260301). Itsmodelis required and names the advisor model (docs). - the OpenAI Responses
image_generationtool. Itsmodelis optional and selects the image model (docs).
relay/helper.ModelMappedHelper
request.model alias -> mapped upstream name
- request.tools[].model alias forwarded unchanged
Evidence
-
Version / deploy / database: tag
v1.0.0-rc.52(04dfcbb71), built from source with Go 1.27.4 on macOS arm64, SQLite, one instance. Pass-through is off. -
Actual: the upstream receives the mapped top-level model and the unmapped tool model.
-
Expected: the channel
model_mappingalso maps the tool model, the same way it maps the top-level model. -
Reproduce: a local mock upstream records the request body that new-api sends.
-
Create an Anthropic channel (type 14) with
base_urlset to the mock and thismodel_mapping:{"ce/claude-opus-5-5": "claude-sonnet-5", "ld/claude-fable-5-2": "claude-opus-5-5"} -
Send this request with header
anthropic-beta: advisor-tool-2026-03-01:curl $BASE/v1/messages -H "x-api-key: $KEY" -H 'anthropic-version: 2023-06-01' \ -H 'anthropic-beta: advisor-tool-2026-03-01' -H 'Content-Type: application/json' \ -d '{"model":"ce/claude-opus-5-5","max_tokens":1024, "tools":[{"type":"advisor_20260301","name":"advisor","model":"ld/claude-fable-5-2"}], "messages":[{"role":"user","content":"hi"}]}'The mock upstream receives:
model = claude-sonnet-5 tools = [{"type": "advisor_20260301", "name": "advisor", "model": "ld/claude-fable-5-2"}] -
Create an OpenAI channel (type 1) with
model_mappingset to{"ce/gpt-5": "gpt-5", "ce/gpt-image-1": "gpt-image-1"}. Then send this request:curl $BASE/v1/responses -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \ -d '{"model":"ce/gpt-5","input":"draw a cat", "tools":[{"type":"image_generation","model":"ce/gpt-image-1"}]}'The mock upstream receives:
model = gpt-5 tools = [{"type": "image_generation", "model": "ce/gpt-image-1"}]
A mock upstream returns 200 for any model name, so the steps above show only the forwarded body. The real Anthropic and OpenAI APIs do not know the alias names
ld/claude-fable-5-2andce/gpt-image-1, so they reject the forwarded request. -
Blast Radius
- Impact: a site that exposes model aliases through
model_mappingcannot serve the advisor tool or a Responsesimage_generationtool with amodel. The client must know the real upstream model name. That name may differ between channels, so one alias cannot route to several channels. - Frequency: every request that sets
tools[].modelto a mapped alias. Requests without a toolmodelare not affected.