Skip to content

Conversation

@charles-cooper
Copy link
Contributor

@charles-cooper charles-cooper commented Dec 14, 2025

implements #5391

Summary

  • Allow users to store multiple API keys for the same provider with named profiles (e.g., separate OpenRouter keys for different cost tracking)
  • Add auth set-default command to swap a named profile to become the default

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
  • Errors: Added ProfileNotFoundError and InvalidProfileNameError

Usage

# First login creates default profile
opencode auth login  # select openrouter, enter key

# Second login prompts for profile name
opencode auth login  # select openrouter, enter "work", enter key

# List shows profiles
opencode auth list
# OpenRouter (default) api
# OpenRouter:work api

# Use profile in model string
opencode --model openrouter:work/claude-sonnet-4

# Swap profiles
opencode auth set-default  # select openrouter, select "work"

Allow users to store multiple API keys for the same provider with named
profiles. Useful for separate cost tracking or different access levels.

- Add profile support to Auth module (get/set/remove/profiles/setDefault)
- Update CLI commands: login prompts for profile, logout/list show profiles
- Add 'auth set-default' command to swap named profile to default
- Support profile in model string format: provider:profile/model
- Add profile field to provider config schema
- Add ProfileNotFoundError and InvalidProfileNameError
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