Skip to content

Add default_providers configuration#687

Open
llenodo wants to merge 3 commits intocrmne:mainfrom
llenodo:feature/default-providers
Open

Add default_providers configuration#687
llenodo wants to merge 3 commits intocrmne:mainfrom
llenodo:feature/default-providers

Conversation

@llenodo
Copy link
Contributor

@llenodo llenodo commented Mar 18, 2026

What this does

Screencast overview: https://www.loom.com/share/d044887130304d64b08eeab0eeee6f82

Adds a default_providers configuration option that routes models to specific providers by model ID prefix, eliminating the need to pass provider: on every call.

RubyLLM.configure do |config|
  config.default_providers = {
    'claude' => :bedrock,            # all claude models route to bedrock
    'claude-haiku' => :anthropic,    # except haiku, which goes direct to anthropic
    'gpt' => :azure,                 # all gpt models route to azure
    'gemini' => :vertexai,           # all gemini models route to vertex ai
    'claude-sonnet-4-5' => :openrouter,  # one specific model via openrouter
  }
end

Longer (more specific) keys take precedence. Explicit provider: arguments always override. Hooks into Models.resolve, so it applies to all model types (chat, embedding, image, transcription, moderation).

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Required for new features

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
    • For provider changes: Re-recorded VCR cassettes with bundle exec rake vcr:record[provider_name]
    • All tests pass: bundle exec rspec
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

AI-generated code

  • I used AI tools to help write this code
  • I have reviewed and understand all generated code (required if above is checked)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

llenodo and others added 2 commits March 18, 2026 09:14
Adds a `default_providers` config option that routes models to specific
providers by model ID prefix, eliminating the need to pass `provider:`
on every call. Longer (more specific) keys take precedence.

Closes crmne#686

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@llenodo llenodo marked this pull request as ready for review March 18, 2026 16:42
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant