Repository navigation
Qwen Code reads four different origin variables — and two of them must NOT be redirected #11541
xizhuomengcontin
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
While building recording support for Qwen Code I had to work out exactly which origin it reads, and the answer turned out to be four separate variables with genuinely different consequences. Writing it down because anyone putting
qwenbehind a proxy or gateway will hit this, and getting it wrong can leak a key to the wrong vendor.Disclosure: I work on OrcaReplay (Apache-2.0). The analysis below is about Qwen Code and holds whatever proxy you use.
The four
OPENAI_BASE_URLANTHROPIC_BASE_URLDASHSCOPE_PROXY_BASE_URLGEMINI_NEXT_GEN_API_BASE_URLThe first two are safe because a proxy can put the right provider back on the other end — the wire dialects are well known and default to
api.anthropic.com/api.openai.com.Why the other two are dangerous to move
Most proxies resolve an upstream by wire dialect, not by provider. So:
POST /v1/chat/completions. That is claimed by the OpenAI dialect and forwarded toapi.openai.com— carrying your DashScope key inAuthorization: Bearer./v1beta/models/…, which no OpenAI/Anthropic dialect claims. Header-sniffing fallbacks typically recognise only Anthropic's header and treat everything else as OpenAI — which sendsx-goog-api-keythe same way.A wrong guess here does not merely fail. It hands one vendor a key issued by another. So the correct behaviour is to leave those two pointing at their own APIs and capture below the agent instead, by terminating TLS.
If you do want to capture Qwen's own models
One host is not enough — the coding plan, regions and token plan all live on different domains:
Note the wildcard
*.dashscope.aliyuncs.comis narrower than it looks: sign-in lives onbailian.console.aliyun.comandmodelstudio.console.alibabacloud.com, different domains entirely.Two smaller findings
WEB_SEARCH_BASE_URLis the web-search tool's endpoint, keyed separately byWEB_SEARCH_API_KEYand off unlessENABLE_WEB_SEARCHis set. Redirecting it without the matching key breaks a tool that works today.Config::get_paramreads the environment beforeconfig.yaml, so a persisted file cannot silently win — which is what makes per-process redirection viable at all.~/.qwen/oauth_creds.json). Inventing anOPENAI_API_KEYin front of that can change which provider answers, so a tool should only supply placeholders when there is genuinely nothing to disturb.What it is for
Recorded sessions can be served back to the agent — same run, no provider called, no tokens spent — or forked from a checkpoint onto a different model. There is an ecosystem PR open at #10895; not asking for review here.
Happy to be told I have any of this wrong; I would rather fix the adapter than keep pinning the wrong variable.
All reactions