How to Use Qwen 27B in Claude Code
Run Qwen3.8-27B behind an Anthropic-compatible endpoint, then set ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL before starting Claude Code.

Summary
- Claude Code needs an Anthropic-compatible endpoint, so an OpenAI-only server needs a translation layer.
- Qwen's model card uses Qwen/Qwen3.8-27B as the model ID for vLLM and SGLang.
- Set ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL before launching claude.
Qwen 27B can run in Claude Code when the server in front of it accepts Claude Code’s Anthropic-format requests. Start Qwen3.8-27B with vLLM or SGLang, add a translation layer if that server exposes only OpenAI Chat Completions, then set ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL.
On this page
The endpoint must speak Claude Code’s format
Claude Code documents ANTHROPIC_BASE_URL as the variable for routing requests through a proxy or gateway, and ANTHROPIC_AUTH_TOKEN as the value used for the Authorization: Bearer header (Claude Code environment variables). Claude Code therefore needs an endpoint that understands the Anthropic Messages request shape. For another Claude Code setup, see Muse Ember with Meta's API.
Qwen’s model card provides OpenAI-compatible Chat Completions examples for Qwen3.8-27B, including /v1/chat/completions and the model ID Qwen/Qwen3.8-27B (Qwen3.8-27B model card). An OpenAI-only server does not automatically become an Anthropic Messages server. Put an adapter or gateway between Claude Code and that server when the server does not expose /v1/messages.
The request path should look like this:
Claude Code → Anthropic-compatible adapter → vLLM or SGLang → Qwen3.8-27B
The adapter decides how Anthropic fields, streaming events, tool calls, and model parameters map to the backend’s OpenAI-compatible API. Check its documentation for the exact upstream URL and supported features before you rely on tools or extended thinking.
Start Qwen3.8-27B with vLLM
Qwen’s model card gives this vLLM command:
pip install vllm
vllm serve "Qwen/Qwen3.8-27B"
The model card then calls the OpenAI-compatible endpoint at http://localhost:8000/v1/chat/completions with the same model ID:
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Qwen/Qwen3.8-27B",
"messages": [
{
"role": "user",
"content": "Write a Python function that merges two sorted linked lists."
}
]
}'
A successful response is a JSON Chat Completions response from port 8000. This confirms the vLLM side is serving Qwen. It does not confirm that Claude Code can use the server directly, because Claude Code sends Anthropic-format requests.
Start Qwen3.8-27B with SGLang
Qwen also documents SGLang serving:
pip install sglang
python3 -m sglang.launch_server \
--model-path "Qwen/Qwen3.8-27B" \
--host 0.0.0.0 \
--port 30000
Check the SGLang endpoint with:
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Qwen/Qwen3.8-27B",
"messages": [
{
"role": "user",
"content": "Explain this repository structure in one paragraph."
}
]
}'
If the response contains the assistant message, SGLang is reachable on port 30000. Configure your adapter to forward translated requests to that URL.
Set Claude Code variables
After you have an Anthropic-compatible adapter endpoint, export the values before launching Claude Code. Replace the URL and key with the values supplied by your adapter or gateway. For a similar setup, see Gemini 4 setup in Claude Code.
export ANTHROPIC_BASE_URL="http://localhost:9000"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"
export ANTHROPIC_MODEL="Qwen/Qwen3.8-27B"
claude
ANTHROPIC_MODEL selects the model name Claude Code sends. Keep the backend name exactly as the serving layer expects it. If your adapter exposes a different public model ID, use that ID instead of Qwen/Qwen3.8-27B.
For a persistent configuration, add the variables under env in ~/.claude/settings.json. Claude Code documents that this file applies to every project for your user account (settings files and precedence):
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:9000",
"ANTHROPIC_AUTH_TOKEN": "sk-your-key",
"ANTHROPIC_MODEL": "Qwen/Qwen3.8-27B"
}
}
The JSON must be strict: remove comments and trailing commas. Start a new claude session after changing shell variables. Inside Claude Code, run /status to inspect which settings source loaded. Claude Code also gives command-line settings and managed settings higher precedence in some situations, so a project or organization configuration can replace your user value.
Check the first Claude Code request
Start Claude Code in a small test repository and ask it to perform a read-only task, such as listing files. You should see a response from the configured model and the adapter logs should show an incoming Anthropic request followed by an upstream Chat Completions request.
If Claude Code reports an authentication error, verify that ANTHROPIC_AUTH_TOKEN matches the adapter’s expected credential and that the adapter forwards it in the format its documentation requires. If it reaches the adapter but fails with an unknown model, compare the value of ANTHROPIC_MODEL with the model name returned by the vLLM or SGLang server.
Context and reasoning settings
Qwen’s model card lists a native context length of 262,144 tokens and says it can be extended to 1,000,000 tokens. The serving framework and adapter still control the context limit that Claude Code can use. Do not assume the largest model-card limit is enabled in your deployment.
Qwen3.8 runs in thinking mode by default. The model card documents reasoning_effort values xhigh, medium, and low, plus preserve_thinking; it also notes that support for sampling parameters varies by inference framework. Pass these fields only when your adapter and server document the corresponding mapping.
Not confirmed yet
The public Qwen model card confirms OpenAI-compatible serving, while Claude Code documents Anthropic-compatible routing. The sources do not establish that a particular adapter supports every Claude Code tool call, streaming event, prompt-caching field, or thinking parameter with Qwen3.8-27B. Verify those capabilities in the adapter’s own documentation before using Claude Code for unattended changes.
Qwen’s qwen-code repository has a v1.x milestone, but that milestone does not document Claude Code compatibility. Qwen3.8-27B is also not listed in the current SeedRouter model directory, so SeedRouter should not be presented as a provider for this model.