Skip to content

Conversation

codearranger
Copy link

TLDR

Fixed the --model parameter being ignored when using a custom base URL. The CLI now correctly respects the model specified via -m or --model flags when using alternative API endpoints.

Dive Deeper

The issue was in the createContentGeneratorConfig function in packages/core/src/core/contentGenerator.ts. When using OpenAI auth type (triggered when a custom base URL is set), the code was overriding the model selection with the OPENAI_MODEL environment variable or falling back to DEFAULT_QWEN_MODEL, completely bypassing the model specified through the CLI's --model parameter.

The fix ensures proper priority ordering:

  1. Model from config (includes CLI --model parameter) - highest priority
  2. Environment variable (OPENAI_MODEL or QWEN_MODEL) - fallback
  3. Default model constant - last resort

This same logic was applied to both OpenAI and QWEN OAuth authentication paths to ensure consistency.

Reviewer Test Plan

To validate this fix:

  1. Test with custom base URL and model parameter:

    export OPENAI_API_KEY="your-key"
    export OPENAI_BASE_URL="https://your-custom-endpoint.com"
    qwen --model gpt-4 "test prompt"
    # Should use gpt-4, not qwen3-coder-plus or coder-model
  2. Test that environment variable still works as fallback:

    export OPENAI_MODEL="gpt-3.5-turbo"
    qwen "test prompt"  # No --model flag
    # Should use gpt-3.5-turbo from env var
  3. Test precedence (CLI flag should override env var):

    export OPENAI_MODEL="gpt-3.5-turbo"
    qwen --model gpt-4 "test prompt"
    # Should use gpt-4 from CLI, not gpt-3.5-turbo from env

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Fixes #654

@codearranger codearranger changed the title fix for issue #654 Fix issue #654 Respect --model parameter when using custom base URL Sep 24, 2025
@Mingholy
Copy link
Collaborator

Looks good. But just to confirm: users can change the model manually in interactive mode, model from config(using config.getModel()) is not always the same as cli args. What's your expectation in this case?

@github-actions github-actions bot added bug priority/P1 High priority issue status/need-retesting Issue needs to be retested on the latest version labels Sep 29, 2025
@bbartels
Copy link

Looks good. But just to confirm: users can change the model manually in interactive mode, model from config(using config.getModel()) is not always the same as cli args. What's your expectation in this case?

I suppose that is fine, it should prioritise the --model parameter, but if the user changes it interactively then it should be preferring that.

@bbartels
Copy link

Would be good to get this change in @Mingholy as the current behaviour is quite confusing

@github-actions github-actions bot added type/bug Something isn't working as expected and removed bug labels Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/P1 High priority issue status/need-retesting Issue needs to be retested on the latest version type/bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--model parameter ignored when using a different baseurl

3 participants