Skip to content

feat(rig-core): add optional model override to CompletionRequest (#1278)#1374

Merged
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
illegalcall:feat-completion-request-model-override-1278
Feb 11, 2026
Merged

feat(rig-core): add optional model override to CompletionRequest (#1278)#1374
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
illegalcall:feat-completion-request-model-override-1278

Conversation

@illegalcall
Copy link
Copy Markdown
Contributor

Summary

Implements #1278 by adding a request-scoped model override to CompletionRequest, allowing callers to override the model selected in T: CompletionModel (needed for batch workflows).

Fixes #1278

Problem

Today, model selection is fixed by the CompletionModel instance. Batch-style or mixed-model workflows need a way to override model per request.

Implementation

  • Added model: Option<String> to CompletionRequest.
  • Added builder APIs:
    • CompletionRequestBuilder::model(...)
    • CompletionRequestBuilder::model_opt(...)
  • Wired model resolution across provider conversions using the pattern:
    • use req.model when provided
    • fallback to provider/default model otherwise
  • Updated path-based providers so routing uses the effective request model:
    • Gemini
    • HuggingFace
    • OpenRouter
  • Updated internal struct literals and tests to include model: None where needed.

Tests

Validated with:

  • cargo check -p rig-core
  • cargo test -p rig-core openai_request_uses_ -- --nocapture
  • cargo test -p rig-core openrouter_request_uses_ -- --nocapture
  • cargo test -p rig-core resolve_request_model_uses_ -- --nocapture
  • cargo test -p rig-core huggingface_request_uses_ -- --nocapture

New focused tests were added for override/fallback behavior in:

  • OpenAI request conversion
  • OpenRouter request conversion
  • Gemini request-model resolver + endpoint construction
  • HuggingFace request conversion

Public API breakage and migration path

Breaking

  • completion::CompletionRequest added a new public field:
    • model: Option<String>
  • Any downstream manual struct literal construction of CompletionRequest now requires this field.

Migration

  • For existing behavior, set:
    • model: None
  • To override model per request, set:
    • model: Some("provider-model-id".to_string())
  • Preferred API:
    • completion_request(...).model("provider-model-id")

Risk / remaining failure points

  • Runtime provider validation can still fail for invalid/unsupported override model IDs.
  • Provider/deployment-specific restrictions (especially path/deployment scoped backends) can reject overrides even when compile-time checks pass.
  • Full-repo cargo test may still include unrelated failures outside this change scope.

Add an optional per-request model field to CompletionRequest so callers can override the default model selected in T: CompletionModel.

- add CompletionRequest.model: Option<String>
- add CompletionRequestBuilder::model(...) and model_opt(...)
- propagate request-level model override through provider request conversions
- update path-based providers (Gemini/HuggingFace/OpenRouter) to use effective model for endpoint routing
- add override/fallback unit tests for OpenAI/OpenRouter/Gemini/HuggingFace
- update struct literals in tests/builders to include model: None

Fixes 0xPlaygrounds#1278
@illegalcall
Copy link
Copy Markdown
Contributor Author

@joshua-mo-143 Can this please be reviewed 🙂

Copy link
Copy Markdown
Contributor

@joshua-mo-143 joshua-mo-143 left a comment

Choose a reason for hiding this comment

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

lgtm I think? doesn't seem to break anything

@illegalcall
Copy link
Copy Markdown
Contributor Author

@joshua-mo-143 I dont see the merge button, not sure why?

@joshua-mo-143
Copy link
Copy Markdown
Contributor

@joshua-mo-143 I dont see the merge button, not sure why?

The merge button is strictly limited to maintainers and we use merge queue to manage merging multiple PRs at once, as otherwise it'll screw with the release-plz stuff 🙂

@joshua-mo-143 joshua-mo-143 added this pull request to the merge queue Feb 11, 2026
Merged via the queue into 0xPlaygrounds:main with commit fed7c33 Feb 11, 2026
5 checks passed
@illegalcall
Copy link
Copy Markdown
Contributor Author

Okay got it. Thank you. Would love to continue contributing here, feel free to mention me in any issue you think.

@github-actions github-actions Bot mentioned this pull request Feb 10, 2026
ThomasMarches pushed a commit to ThomasMarches/rig that referenced this pull request Feb 13, 2026
…laygrounds#1374)

Add an optional per-request model field to CompletionRequest so callers can override the default model selected in T: CompletionModel.

- add CompletionRequest.model: Option<String>
- add CompletionRequestBuilder::model(...) and model_opt(...)
- propagate request-level model override through provider request conversions
- update path-based providers (Gemini/HuggingFace/OpenRouter) to use effective model for endpoint routing
- add override/fallback unit tests for OpenAI/OpenRouter/Gemini/HuggingFace
- update struct literals in tests/builders to include model: None

Fixes 0xPlaygrounds#1278
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.

feat: add model field to CompletionRequest

2 participants