Skip to content

Qwen Code ignoring .env and environmental variables - Not using local llm #599

@Sehyo

Description

@Sehyo

What happened?

I am hosting Qwen3 Coder 30B 3A on llama.cpp, and works fine with other tools.
I have set the .env in project directory such as this:

OPENAI_API_KEY=sk-qwen
OPENAI_MODEL=qwen
OPENAI_BASE_URL=http://127.0.0.1:8080/v1

I also have them exported, sanity check:

volatile@Adams-MacBook-Pro test-1 % echo $OPENAI_MODEL
qwen
volatile@Adams-MacBook-Pro test-1 % echo $OPENAI_API_KEY
sk-qwen
volatile@Adams-MacBook-Pro test-1 % echo $OPENAI_BASE_URL
http://127.0.0.1:8080/v1

The alias for the model is simply "qwen":
{"models":[{"name":"qwen","model":"qwen","modified_at":"","size":"","digest":"","type":"model","description":"","tags":[""],"capabilities":["completion"],"parameters":"","details":{"parent_model":"","format":"gguf","family":"","families":[""],"parameter_size":"","quantization_level":""}}],"object":"list","data":[{"id":"qwen","object":"model","created":1757788577,"owned_by":"llamacpp","meta":{"vocab_type":2,"n_vocab":151936,"n_ctx_train":262144,"n_embd":2048,"n_params":30532122624,"size":32477962240}}]}

However, when I start qwen code from the project directory with the .env file, it uses the cloud version, not local model. This is what I see at the bottom:
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
~/projects/test-1 no sandbox (see /docs) qwen3-coder-plus (100% context left)

What did you expect to happen?

Qwen Coder CLI should use local model through the given environmental variables.

Client information

$ qwen /about
# paste output here

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/P1High priority issuestatus/need-informationMore information is needed to resolve this issue.type/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions