Skip to content

feat: route model slots to different provider profiles (multi-provider in one session) #16

Description

@Whiteknight07

Duplicate Check / 重复检查

  • I have searched existing issues and this is not a duplicate / 我已搜索现有 issue,确认非重复

Problem / 问题

Today a profile maps all Claude Code model slots (haiku/sonnet/opus) to a single provider backend (base_url). [profiles.models] only renames the model string — it can't route, e.g., haiku requests to a cheap provider while sonnet/opus go to a premium one.

Use case: I'd like to run one Claude Code session where:

  • haiku slot → OpenCode Go (deepseek-v4-flash, API key)
  • sonnet/opus slots → ChatGPT Codex subscription (gpt-5.6-terra / gpt-5.6-sol, OAuth)

Proposed Solution / 建议方案

Allow each model slot to optionally reference a different profile:

[[profiles]]
name = "codex-sub"
provider_type = "OpenAIResponses"
base_url = "https://chatgpt.com/backend-api/codex"
default_model = "gpt-5.6-sol"
auth_type = "oauth"
oauth_provider = "openai"

[profiles.slot_profiles]
haiku = "opencode-go"   # route haiku requests to another profile

Implementation sketch (proxy-side, in handle_messages):

  1. After resolving the primary profile, inspect body["model"].
  2. If it matches a slot that has a slot_profiles override, re-resolve that profile (its adapter, base_url, auth, strip_params).
  3. Reuse the existing translation/streaming/failover machinery — only the target ProfileConfig changes.

This keeps the change small: config struct + one routing decision in handler.rs. Launch behavior (ANTHROPIC_DEFAULT_*_MODEL) is unchanged — the model name string is already sent per-slot.

Alternatives Considered / 备选方案

  • Separate profiles per provider and switch sessions manually (current workaround — doesn't give mixed slots in one session).
  • Smart Router ([router.rules]) — intent-based, but not per-slot and requires a classifier.

Additional Context / 补充信息

Happy to work on this and open a PR with tests + bilingual docs. Let me know if you'd prefer a different config shape.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions