Skip to content

Conversation

@lygaret
Copy link

@lygaret lygaret commented Dec 26, 2025

in order to provide different anthropic credentials depending on the project (eg, when you don't want to use your work's Claude subscription for personal projects), I need a way to utilize this plugin's already existing handling of oauth, and just override the name.

After merging, default behavior stays the same, but custom plugins will be able to create custom anthropic sessions:


Example

  1. create custom plugin, which uses this package;
// ~/.config/opencode/plugins/anthropic-personal.mjs

import { makeAnthropicProviderPlugin } from 'opencode-anthropic-auth'
export async function AnthropicPersonalAuthPlugin({ client }) {
  return makeAnthropicProviderPlugin('anthropic-personal', client);
}
  1. update ~/.config/opencode/opencode.json to reference the plugin and add models
{
  "plugin": [
    "file:///Users/jonathan/.config/opencode/plugin/anthropic-personal.mjs"
  ],
  "provider": {
    "anthropic-personal": {
      "npm": "@ai-sdk/anthropic",
      "name": "Anthropic (Personal)",
      "models": {
        "claude-sonnet-4-5": {
          "name": "Claude Sonnet 4.5"
        }
      }
    }
  }
}

(note that until this PR is merged, the import won't work, so this whole thing will need to go in a full package, with a package.json referencing the fork, etc., once merged, the import will resolve to the bun packaged version, and this should be it.

  1. choose a model and connect

in order to provide different anthropic credentials depending on the project (eg, when you don't want to use your work's Claude subscription for personal projects), we need a way to utilize this plugin's already existing handling of oauth, and just override the name.

After merging, default behavior stays the same, but custom plugins will be able to create custom anthropic sessions.
@lygaret lygaret marked this pull request as ready for review December 26, 2025 23:43
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