Skip to content

feat(auth): add support for multiple profiles per provider#36781

Open
muhedin998 wants to merge 6 commits into
anomalyco:devfrom
muhedin998:feat/multi-profile-auth
Open

feat(auth): add support for multiple profiles per provider#36781
muhedin998 wants to merge 6 commits into
anomalyco:devfrom
muhedin998:feat/multi-profile-auth

Conversation

@muhedin998

@muhedin998 muhedin998 commented Jul 13, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #5391

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Allow users to store multiple API keys for the same provider with named profiles (e.g., separate OpenRouter keys for different cost tracking).

Changes:

  • Auth module: Added profile support to get/set/remove, plus profiles(), hasDefault(), setDefault() functions. Key format: providerID for default, providerID:profileName for named profiles.
  • CLI commands: login prompts for profile name when default exists, logout/list show profile names, new set-default command.
  • Provider: parseModel() extracts profile from provider:profile/model format.
  • Config: Added optional profile field to provider schema.

How did you verify your code works?

  • TypeScript typecheck passes for both packages/opencode and packages/core
  • Added unit tests for:
    • Auth profiles: set/get with profiles, list profiles, hasDefault, setDefault swap, remove with profile
    • parseKey/buildKey/validateProfileName utilities
    • parseModel with provider:profile/model format

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@muhedin998
muhedin998 force-pushed the feat/multi-profile-auth branch from 246e623 to 75c0ace Compare July 14, 2026 13:06
Allow users to store multiple API keys for the same provider with named
profiles (e.g., separate OpenRouter keys for different cost tracking).

Changes:
- Auth module: Added profile support to get/set/remove, plus profiles(),
  hasDefault(), setDefault() functions
- CLI commands: login prompts for profile name when default exists,
  logout/list show profile names, new set-default command
- Provider: parseModel() extracts profile from provider:profile/model format
- Config: Added optional profile field to provider schema

Key format: 'providerID' for default, 'providerID:profileName' for named.

Usage:
  opencode auth login        # first login creates default
  opencode auth login        # second login prompts for profile name
  opencode auth list         # shows all profiles grouped by provider
  opencode auth set-default  # swap a named profile to be the default
  opencode auth logout       # shows profiles in selection

Model string format:
  openrouter:work/claude-sonnet-4  # uses 'work' profile
  openrouter/claude-sonnet-4       # uses default profile

Closes anomalyco#5391
- Auth profiles: set/get with profiles, list profiles, hasDefault,
  setDefault swap, remove with profile
- parseKey/buildKey/validateProfileName utilities
- parseModel with provider:profile/model format
@muhedin998
muhedin998 force-pushed the feat/multi-profile-auth branch from 0c42281 to f7e31f0 Compare July 14, 2026 23:37
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.

[FEATURE]: multiple auth profiles per provider

1 participant