Anthropic (Claude) Integration Plan
Status: shipped (November 20, 2025) Scope: API support for Claude 4.5 Sonnet and Claude 4.1 Opus in Oracle CLI.
#Models & Pricing (public list prices)
- claude-sonnet-4-6 (CLI alias:
claude-4.6-sonnet) — 200k context, ~$3 / 1M input tokens, ~$15 / 1M output tokens. - claude-opus-4-1 (CLI alias:
claude-4.1-opus) — 200k context, ~$15 / 1M input tokens, ~$75 / 1M output tokens. - Prompt-caching premium (not modeled in CLI costs): cached input portion >200k is billed higher (Sonnet ~$6 / 1M; Opus ~$18.75 / 1M).
#Requirements
- Environment:
ANTHROPIC_API_KEY(required),ANTHROPIC_BASE_URL(optional; defaults tohttps://api.anthropic.com). - Engine: API only. Browser mode is blocked for Claude.
- Tokenizer:
@anthropic-ai/tokenizer(wrapped to accept Oracle’s array inputs). Estimates are approximate; rely on APIusagefor actual billing.
#Planned CLI Behavior
- Add models to
--model/--models:claude-4.6-sonnet,claude-4.1-opus. Aliases: “sonnet”, “opus” map to those IDs. - Background runs: disabled for Claude (
supportsBackground=false). Even if--backgroundis set, the run streams normally and logs a note. - Search / tools:
web_search_previewis ignored for Claude;--searchis effectively off with a warning. - Base URL:
--base-url/apiBaseUrlapplies per provider; falls back toANTHROPIC_BASE_URLfor Claude,OPENAI_BASE_URLfor GPT. - Cost display: uses the prices above; prompt-caching billing is not modeled (estimates are upper/lower bounds only).
#Usage Examples
- Single model (Sonnet):
- High-reasoning (Opus) with files report:
- Multi-model compare (GPT + Claude):
``bash oracle --engine api --model claude-4.6-sonnet --prompt "Summarize the design doc" --file docs/design.md ``
``bash oracle -m claude-4.1-opus --files-report --prompt "Analyze risk register" --file docs/risk.md ``
``bash oracle --models gpt-5.1-pro,claude-4.6-sonnet --prompt "Propose mitigation steps" --file docs/plan.md `` Background stays off for Claude; GPT may still use background.
#Implementation Notes (for maintainers)
- Types/config: Claude entries use
apiModelmapping to Anthropic IDs (claude-sonnet-4-6,claude-opus-4-1); Opus stays inProModelName; pricing + 200k inputLimit; Anthropic tokenizer wrapper;supportsBackground=false. Opus getsreasoning: high. - Client factory: branch on
claude*to the Anthropic adapter (messages.stream/create); pass provider-specificbaseUrl. - Env selection:
ANTHROPIC_API_KEYandANTHROPIC_BASE_URL; log masked key per provider. - Token estimates: wrapper flattens Oracle message arrays into text before calling
countTokens. - Multi-model: shared
runOptions.backgroundis gated by per-modelsupportsBackground; Claude never enters the background polling path. - Docs to update alongside code: this file,
README.mdmodel list,docs/configuration.md,docs/multimodel.md.
#Limitations / Caveats
- Token estimates for Claude are approximate; API may still reject >200k inputs even if estimate passes.
- Prompt-caching cost deltas are not reflected in CLI estimates.
- No tool use/search for Claude in v1.
#Troubleshooting
- Missing key: “Missing ANTHROPICAPIKEY…” — set the env var or pass
--api-key. - Background ignored: expected; Claude does not support the Responses-style job API.
- Search ignored: expected; Claude adapter currently drops
web_search_preview.
#Next Steps (post-v1)
- Optional: add tool/use support with a provider-agnostic tool layer.
- Add dated model-id mapping if Anthropic starts versioned IDs (similar to Gemini resolver) — currently aliases map to the undated IDs above.
- Improve cost estimation if API exposes cached-token counters.