Drupal is a registered trademark of Dries Buytaert

Overview

Enables Anthropic Claude AI models in Drupal using long-lived OAuth setup tokens from your Claude subscription (Pro/Max/Team). This is an alternative to the standard API key authentication, designed for developers with existing Claude subscriptions who want to use their subscription benefits instead of separate API billing.

⚠️ Terms of Service Notice

Important: OAuth setup tokens from claude setup-token are officially intended for Claude Code CLI use. Using these tokens in third-party applications may violate Anthropic's Terms of Service.

For production use, please install AI Provider Anthropic and use official API keys from the Anthropic Console.

Appropriate use cases: Personal development, testing, internal tools, proof-of-concept projects.

Key Features

  • Bearer Authentication: Uses Authorization: Bearer with OAuth setup tokens
  • Long-lived Tokens: Tokens valid for ~1 year, no automatic refresh needed
  • Dynamic Model Discovery: Fetches available models from Anthropic API automatically
  • Secure Storage: Integrates with Key module for credential management
  • Automatic Token Validation: Tests tokens against live API on configuration
  • Full AI Module Integration: Works with all AI module operations (chat, JSON output, tools)
  • 9+ Claude Models: Supports Claude Opus 4.6, Sonnet 4.6, Haiku 4.5, and more

How It Works

This module uses OAuth access tokens obtained from the Claude CLI:

  1. Run claude setup-token to generate a token
  2. Store the token securely using Drupal's Key module
  3. Select the Key in the module configuration
  4. The module automatically validates the token against Anthropic's API

Tokens are valid for approximately one year. When a token expires, simply generate a new one and update your Key — no complex OAuth refresh flow needed.

Technical Details

Authentication Method

OAuth tokens use Bearer authentication with a special beta header required by Anthropic:

  • Authorization: Bearer sk-ant-oat01-...
  • anthropic-beta: oauth-2025-04-20
  • anthropic-version: 2023-06-01

Architecture

  • Extends: OpenAiBasedProviderClientBase
  • Token Storage: Key module (required dependency)
  • Model Discovery: Dynamic fetching from /v1/models API endpoint
  • Fallback: Hardcoded model list if API is unavailable
  • Dependency Injection: Follows Drupal 11 best practices throughout

Requirements

  • Drupal 10.3+ or 11
  • AI module (1.x)
  • Key module (1.x) — Required
  • Anthropic account with Claude Pro, Max, or Team subscription
  • Claude CLI installed: npm install -g @anthropic-ai/claude-code

Installation & Configuration

1. Install the Module

composer require drupal/ai_anthropic_provider_oauth
drush en ai_anthropic_provider_oauth

2. Generate an OAuth Token

claude setup-token

This opens your browser for authentication and generates a token starting with sk-ant-oat01-

3. Create a Key

Navigate to Admin → Configuration → System → Keys (/admin/config/system/keys)

  • Click "Add key"
  • Name: Anthropic OAuth Token
  • Key type: Authentication
  • Key provider: Configuration (dev) or Environment variable (production)
  • Paste your token in the Key value field
  • Save

4. Configure the Provider

Navigate to Admin → Configuration → AI → Providers → Anthropic OAuth (/admin/config/ai/providers/anthropic-oauth)

  • Select your Key in the "Access Token Configuration" section
  • Save configuration
  • The page will automatically validate your token against the Anthropic API

Available Models

The module dynamically fetches models from Anthropic's API. Current models include:

  • Claude Opus 4.6 — Most capable model for complex tasks
  • Claude Sonnet 4.6 — Balanced performance and speed
  • Claude Haiku 4.5 — Fast and efficient
  • And more (models update automatically)

Use Cases

✅ Appropriate Use

  • Personal development and testing environments
  • Internal tools for your organization (with active Claude subscription)
  • Proof-of-concept and experimental projects
  • Learning and exploring AI capabilities
  • Websites where costs effectiveness is a key factor

❌ Not Recommended For

  • Production websites serving external users
  • Commercial applications
  • High-volume API usage
  • Mission-critical applications

For production use: Install AI Provider Anthropic with official API keys.

Comparison with AI Provider Anthropic

Feature ai_anthropic_provider_oauth ai_provider_anthropic Authentication OAuth Bearer tokens API keys (x-api-key) Token Source claude setup-token Anthropic Console Token Validity ~1 year Until revoked Billing Uses subscription Separate API billing ToS Compliance Uncertain (third-party use) Fully compliant Production Use Not recommended Recommended

Troubleshooting

"No access token configured"

  1. Verify you created a Key at /admin/config/system/keys
  2. Verify you selected that Key in the module config
  3. Run claude setup-token if you haven't generated a token

"Token validation failed"

Your token may be expired or revoked:

  1. Run claude setup-token to generate a fresh token
  2. Update your Key with the new token value
  3. Verify your Claude subscription is active

Related Modules

  • AI — Base AI module framework
  • AI Provider Anthropic — Official API key provider (recommended for production)
  • Key — Secure credential storage

Activity

Total releases
4
First release
Mar 2026
Latest release
1 day ago
Release cadence
0 days
Stability
0% stable

Release Timeline

Releases

Version Type Release date
1.0.0-beta1 Pre-release Mar 13, 2026
1.0.0-alpha2 Pre-release Mar 12, 2026
1.0.0-alpha1 Pre-release Mar 12, 2026
1.0.x-dev Dev Mar 12, 2026