|
| 1 | +import type { ModelInfo } from "../model.js" |
| 2 | + |
| 3 | +/** |
| 4 | + * Claude Code (Subscription) Provider |
| 5 | + * |
| 6 | + * This provider shells out to the user's own locally-installed and |
| 7 | + * already-authenticated `claude` CLI (Pro/Max/Team/Enterprise subscription), |
| 8 | + * instead of an Anthropic API key. No credentials are read, stored, or |
| 9 | + * transmitted by this extension. |
| 10 | + * |
| 11 | + * Key differences from anthropic: |
| 12 | + * - Uses the local CLI session instead of API keys |
| 13 | + * - Subscription-based pricing (no per-token costs) |
| 14 | + * - Model availability depends on the authenticated subscription |
| 15 | + * |
| 16 | + * Pricing below (0 at runtime) mirrors the real per-token list prices from |
| 17 | + * `anthropic.ts` as of 2026-07-04, for reference only. |
| 18 | + * |
| 19 | + * contextWindow/maxTokens are grounded against live `claude --model <id> |
| 20 | + * --output-format json` output (`modelUsage[id].contextWindow` / |
| 21 | + * `.maxOutputTokens`) rather than copied from `anthropic.ts`, since the |
| 22 | + * Agent SDK/CLI path reports different max output caps than the direct API |
| 23 | + * for the same model name (e.g. 64K here vs. 128K direct for Opus/Sonnet 5/ |
| 24 | + * Fable 5, 32K here vs. 64K direct for Haiku 4.5/Sonnet 4.6). |
| 25 | + * |
| 26 | + * `claude-sonnet-4-6[1m]` is a distinct, explicitly-selected model key (not |
| 27 | + * a flag) that reports contextWindow: 1_000_000 vs. 200_000 for the bare |
| 28 | + * `claude-sonnet-4-6` id. `claude-opus-4-6[1m]` was tried and did not |
| 29 | + * resolve to a model (empty modelUsage), so no 1M variant is listed for it. |
| 30 | + */ |
| 31 | + |
| 32 | +export type ClaudeCodeModelId = keyof typeof claudeCodeModels |
| 33 | + |
| 34 | +export const claudeCodeDefaultModelId: ClaudeCodeModelId = "claude-sonnet-5" |
| 35 | + |
| 36 | +/** |
| 37 | + * Models available through the Claude Code CLI subscription flow. |
| 38 | + * Costs are 0 as they are covered by the subscription. |
| 39 | + */ |
| 40 | +export const claudeCodeModels = { |
| 41 | + "claude-fable-5": { |
| 42 | + maxTokens: 64_000, |
| 43 | + contextWindow: 1_000_000, |
| 44 | + supportsImages: true, |
| 45 | + supportsPromptCache: true, |
| 46 | + // List price: $10/$50 per million in/out, $12.50 cache write, $1.00 cache read. |
| 47 | + inputPrice: 0, |
| 48 | + outputPrice: 0, |
| 49 | + cacheWritesPrice: 0, |
| 50 | + cacheReadsPrice: 0, |
| 51 | + supportsReasoningBudget: true, |
| 52 | + supportsReasoningBinary: true, |
| 53 | + supportsTemperature: false, |
| 54 | + description: "Claude Fable 5 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 55 | + }, |
| 56 | + "claude-opus-4-8": { |
| 57 | + maxTokens: 64_000, |
| 58 | + contextWindow: 1_000_000, |
| 59 | + supportsImages: true, |
| 60 | + supportsPromptCache: true, |
| 61 | + // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. |
| 62 | + inputPrice: 0, |
| 63 | + outputPrice: 0, |
| 64 | + cacheWritesPrice: 0, |
| 65 | + cacheReadsPrice: 0, |
| 66 | + supportsReasoningBudget: true, |
| 67 | + supportsReasoningBinary: true, |
| 68 | + supportsTemperature: false, |
| 69 | + description: "Claude Opus 4.8 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 70 | + }, |
| 71 | + "claude-opus-4-7": { |
| 72 | + maxTokens: 64_000, |
| 73 | + contextWindow: 1_000_000, |
| 74 | + supportsImages: true, |
| 75 | + supportsPromptCache: true, |
| 76 | + // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. |
| 77 | + inputPrice: 0, |
| 78 | + outputPrice: 0, |
| 79 | + cacheWritesPrice: 0, |
| 80 | + cacheReadsPrice: 0, |
| 81 | + supportsReasoningBudget: true, |
| 82 | + supportsReasoningBinary: true, |
| 83 | + supportsTemperature: false, |
| 84 | + description: "Claude Opus 4.7 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 85 | + }, |
| 86 | + "claude-opus-4-6": { |
| 87 | + maxTokens: 64_000, |
| 88 | + contextWindow: 200_000, |
| 89 | + supportsImages: true, |
| 90 | + supportsPromptCache: true, |
| 91 | + // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. |
| 92 | + inputPrice: 0, |
| 93 | + outputPrice: 0, |
| 94 | + cacheWritesPrice: 0, |
| 95 | + cacheReadsPrice: 0, |
| 96 | + supportsReasoningBudget: true, |
| 97 | + description: "Claude Opus 4.6 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 98 | + }, |
| 99 | + "claude-sonnet-5": { |
| 100 | + maxTokens: 64_000, |
| 101 | + contextWindow: 1_000_000, |
| 102 | + supportsImages: true, |
| 103 | + supportsPromptCache: true, |
| 104 | + // List price: $2/$10 per million in/out (introductory, through Aug 31, 2026), |
| 105 | + // $2.50 cache write, $0.20 cache read. |
| 106 | + inputPrice: 0, |
| 107 | + outputPrice: 0, |
| 108 | + cacheWritesPrice: 0, |
| 109 | + cacheReadsPrice: 0, |
| 110 | + supportsReasoningBudget: true, |
| 111 | + supportsReasoningBinary: true, |
| 112 | + supportsTemperature: false, |
| 113 | + description: "Claude Sonnet 5 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 114 | + }, |
| 115 | + "claude-sonnet-4-6": { |
| 116 | + maxTokens: 32_000, |
| 117 | + contextWindow: 200_000, |
| 118 | + supportsImages: true, |
| 119 | + supportsPromptCache: true, |
| 120 | + // List price: $3/$15 per million in/out, $3.75 cache write, $0.30 cache read. |
| 121 | + inputPrice: 0, |
| 122 | + outputPrice: 0, |
| 123 | + cacheWritesPrice: 0, |
| 124 | + cacheReadsPrice: 0, |
| 125 | + supportsReasoningBudget: true, |
| 126 | + description: "Claude Sonnet 4.6 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 127 | + }, |
| 128 | + "claude-sonnet-4-6[1m]": { |
| 129 | + maxTokens: 32_000, |
| 130 | + contextWindow: 1_000_000, |
| 131 | + supportsImages: true, |
| 132 | + supportsPromptCache: true, |
| 133 | + // Same list price as claude-sonnet-4-6; [1m] only changes context window. |
| 134 | + // Tiered pricing above 200K would apply on the direct Anthropic API path |
| 135 | + // but subscription usage is $0 either way. |
| 136 | + inputPrice: 0, |
| 137 | + outputPrice: 0, |
| 138 | + cacheWritesPrice: 0, |
| 139 | + cacheReadsPrice: 0, |
| 140 | + supportsReasoningBudget: true, |
| 141 | + description: "Claude Sonnet 4.6 (1M context) via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 142 | + }, |
| 143 | + "claude-haiku-4-5-20251001": { |
| 144 | + maxTokens: 32_000, |
| 145 | + contextWindow: 200_000, |
| 146 | + supportsImages: true, |
| 147 | + supportsPromptCache: true, |
| 148 | + // List price: $1/$5 per million in/out, $1.25 cache write, $0.10 cache read. |
| 149 | + inputPrice: 0, |
| 150 | + outputPrice: 0, |
| 151 | + cacheWritesPrice: 0, |
| 152 | + cacheReadsPrice: 0, |
| 153 | + supportsReasoningBudget: true, |
| 154 | + description: "Claude Haiku 4.5 via Claude Code subscription (Pro/Max/Team/Enterprise).", |
| 155 | + }, |
| 156 | +} as const satisfies Record<string, ModelInfo> |
0 commit comments