Skip to content

Thesam1798/opencode-anthropic-auth

 
 

Repository files navigation

OpenCode Anthropic Auth Plugin

An OpenCode plugin that provides Anthropic OAuth authentication, enabling Claude Pro/Max users to use their subscription directly with OpenCode.

Usage

Add the plugin to your OpenCode configuration:

{
  "plugin": ["@ex-machina/opencode-anthropic-auth"]
}

Tip

It is STRONGLY advised that you pin the plugin to a version. This will keep you from getting automatic updates; however, this will protect you from nefarious updates.

This holds true for ANY OpenCode plugin. If you do not pin them, OpenCode will automatically update them on startup. It's a massive vulnerability waiting to happen.

Example of pinned version

{
  "plugin": ["@ex-machina/opencode-anthropic-auth@1.1.1"]
}

Authentication Methods

The plugin provides three authentication options:

  • Claude Pro/Max - OAuth flow via claude.ai for Pro/Max subscribers. Uses your existing subscription at no additional API cost.
  • Create an API Key - OAuth flow via console.anthropic.com that creates an API key on your behalf.
  • Manually enter API Key - Standard API key entry for users who already have one.

How It Works

For Claude Pro/Max authentication, the plugin:

  1. Initiates a PKCE OAuth flow against Anthropic's authorization endpoint
  2. Exchanges the authorization code for access and refresh tokens
  3. Automatically refreshes expired tokens
  4. Injects the required OAuth headers and beta flags into API requests
  5. Zeros out model costs (since usage is covered by the subscription)

Development

Publishing

This project uses changesets for versioning and publishing. See the changeset README for more details.

bun change          # create a changeset describing your changes

When changesets are merged to main, CI will automatically open a release PR. Merging that PR publishes to npm.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

No contributors

Languages

  • TypeScript 100.0%