Skip to content

openrouter model syntax is not supported #2036

Closed

Description

@ilkerhk

Hello,
The model commandline argument is misleading when used with openrouters model syntax using preset.

For example below command just starts and continues working with the last used model and but it doesnt give any error or message to the user that it is not using the model requested :

opencode --model openrouter/qwen/qwen3-coder@preset/fp8-and-higher

I think it should give error, or even better just use whatever the user gave as the model in api calls.

Activity

  1. github-actions commented on Aug 18, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Aug 18, 2025

    @rekram1-node
    Contributor

    @ilkerhk just fyi to use a model you need to prefix with the provider, if you are using openrouter this would be:

    openrouter/qwen/qwen3-coder@preset/fp8-and-higher

  3. ilkerhk commented on Aug 18, 2025

    @ilkerhk
    Author

    @ilkerhk just fyi to use a model you need to prefix with the provider, if you are using openrouter this would be:

    openrouter/qwen/qwen3-coder@preset/fp8-and-higher

    Yes, I am using with provider name. That was a typo in the message, now corrected. Thanks for noticing.

  4. rekram1-node commented on Aug 18, 2025

    @rekram1-node
    Contributor

    Ahh okay I think the issue here is we need to either:

    1. add this model to models.dev
    2. add this model in your opencode config

    I will work on adding it to models.dev for ya

  5. self-assigned this
    on Aug 18, 2025
  6. ilkerhk commented on Aug 18, 2025

    @ilkerhk
    Author

    Ahh okay I think the issue here is we need to either:

    1. add this model to models.dev
    2. add this model in your opencode config

    I will work on adding it to models.dev for ya

    Thank you @rekram1-node
    fp8-and-higher is a preset that I defined. Others might have different and multiple presets so might not be convenient to update config for each model. But I've realized it is possible to use env variables in config,

    Using suggestion of @michabbb in #1439
    somewhat indirect way but below seems to be a workaround

    "provider": {
                    "openrouterCustom": {
                            "npm": "@ai-sdk/openai-compatible",
                            "options": {
                                    "baseURL": "{env:OPENAI_BASE_URL}",
            								  "apiKey": "{env:OPENAI_API_KEY}"
                            },
                            "models": {
    										  "{env:OPENAI_MODEL}": {}
                            }
                    }
            }
    

    With above unspecified provider/model/url in opencode.json now it is possible to use it with any name :

    export OPENAI_API_KEY="sk-XXXX"
    export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
    export OPENAI_MODEL="qwen/qwen3-coder@preset/fp8-and-higher"
    
    opencode --model openrouterCustom/$OPENAI_MODEL
    
  7. rekram1-node commented on Aug 18, 2025

    @rekram1-node
    Contributor

    Ahh that makes sense, I don't use openrouter so I was unfamiliar with the @preset syntax. I completely agree this would be inconvenient to add to models.dev then haha

  8. deleted a comment from linear on Aug 18, 2025
  9. rekram1-node commented on Aug 18, 2025

    @rekram1-node
    Contributor

    Going to close as this is possible using custom config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions