Skip to content

feat(providers): support OpenRouter request parameters#9276

Open
sunilkumarvalmiki wants to merge 1 commit into
aaif-goose:mainfrom
sunilkumarvalmiki:fix/openrouter-parameters-8646
Open

feat(providers): support OpenRouter request parameters#9276
sunilkumarvalmiki wants to merge 1 commit into
aaif-goose:mainfrom
sunilkumarvalmiki:fix/openrouter-parameters-8646

Conversation

@sunilkumarvalmiki
Copy link
Copy Markdown
Contributor

Resolves #8646.

Summary

  • Add optional OPENROUTER_PARAMETERS provider config.
  • Accept both YAML object values and JSON string values for advanced OpenRouter request fields.
  • Merge custom OpenRouter parameters without overwriting Goose-managed request fields.
  • Document YAML and JSON string examples for verbosity, reasoning, and plugins.

Testing

  • cargo fmt --all --check
  • cargo check -p goose --no-default-features --features rustls-tls,local-inference --lib
  • CARGO_BUILD_JOBS=1 cargo test -p goose --no-default-features --features rustls-tls,local-inference --lib openrouter_parameters

@DOsinga DOsinga added this pull request to the merge queue May 18, 2026
@DOsinga DOsinga removed this pull request from the merge queue due to a manual request May 18, 2026
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, actually can you rework this to not duplicate the existing request_params infrastructure? ModelConfig.request_params already gets merged into the OpenAI-compatible payload by create_request() in formats/openai.rs — so the simpler approach is to parse OPENROUTER_PARAMETERS in from_env() and feed it into model_config.request_params there. That way you don't need the apply_openrouter_parameters function, the extra field on the provider struct, or the second merge path with subtly different collision semantics (or_insert vs the existing insert-with-reserved-key-check). Most of the tests can go too since they're just testing serde_json basics.

Signed-off-by: sunilkumarvalmiki <g.sunilkumarvalmiki@gmail.com>
@sunilkumarvalmiki sunilkumarvalmiki force-pushed the fix/openrouter-parameters-8646 branch from 33037fb to bfcc03a Compare May 20, 2026 17:16
@sunilkumarvalmiki
Copy link
Copy Markdown
Contributor Author

Reworked this to use the existing ModelConfig.request_params flow in OpenRouterProvider::from_env() instead of a provider-specific payload merge path. The provider field and apply_openrouter_parameters helper are removed, and the tests now cover parsing plus propagation into both the primary and fast model configs.

Local checks run:

  • cargo fmt --all --check
  • CARGO_BUILD_JOBS=1 cargo test -p goose --no-default-features --features rustls-tls,local-inference --lib openrouter_parameters
  • CARGO_BUILD_JOBS=1 cargo check -p goose --no-default-features --features rustls-tls,local-inference --lib

@sunilkumarvalmiki
Copy link
Copy Markdown
Contributor Author

@DOsinga The requested rework is pushed and CI is green now. Could you take another look when you have a chance?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to configure generic openrouter API parameters

2 participants