ADK.LLM.Anthropic (ADK v0.0.1)

Copy Markdown View Source

Anthropic Claude LLM backend using the Messages API via Req.

Authentication

Supports two auth modes, checked in this order:

OAuth Token (Claude Code CLI / Claude Pro)

Uses Authorization: Bearer header. Sources checked in order:

# Application config
config :adk, :anthropic_oauth_token, "sk-ant-sid02-..."

# Environment variable
ANTHROPIC_OAUTH_TOKEN=sk-ant-sid02-...

# Auto-detected from Claude Code CLI session
CLAUDE_AI_SESSION_KEY=sk-ant-sid02-...

API Key

Uses x-api-key header. Sources checked in order:

# Application config
config :adk, :anthropic_api_key, "sk-ant-api03-..."

# Environment variable
ANTHROPIC_API_KEY=sk-ant-api03-...

Usage

config :adk, :llm_backend, ADK.LLM.Anthropic

ADK.LLM.Anthropic.generate("claude-sonnet-4-20250514", %{
  instruction: "You are helpful.",
  messages: [%{role: :user, parts: [%{text: "Hello"}]}]
})

Summary

Types

auth()

@type auth() :: {:oauth, String.t()} | {:api_key, String.t()}