@skyphusion/create-prism 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Model catalog (v0.18.4).
1
+ // Model catalog.
2
2
  //
3
3
  // Extracted from src/index.ts for navigability. This file is the single
4
4
  // authoritative list of models the worker exposes; adding or removing
@@ -21,6 +21,8 @@
21
21
  // stream parser handles it (Anthropic, xAI, OpenAI, Google, Workers AI
22
22
  // are all covered)
23
23
 
24
+ import { px, TIER_200K, TIER_512K, TIER_UNSTATED, type ModelPricing } from "./pricing";
25
+
24
26
  // "voice" = conversational/streaming STT (a live WebSocket session, not a
25
27
  // one-shot request like "stt"); handled out of /api/chat via /api/stt/stream.
26
28
  export type ModelType = "chat" | "image" | "tts" | "video" | "stt" | "music" | "voice";
@@ -37,7 +39,22 @@ export type Provider =
37
39
  | "pixverse"
38
40
  | "vidu"
39
41
  | "recraft"
40
- | "moonshotai";
42
+ | "moonshotai"
43
+ | "deepseek";
44
+
45
+ // 2026-12 refresh: third-party Unified Billing chat providers whose Cloudflare catalog
46
+ // request format is Chat Completions ({ messages } in, OpenAI-compatible SSE
47
+ // out). They share one dispatch path: env.AI.run with { messages } for
48
+ // POST /api/chat, and callOpenAIStream for POST /api/chat/stream. A provider
49
+ // here must list "Chat Completions" under "Request formats" on its CF model
50
+ // page. alibaba and minimax also carry video/music entries; this set only
51
+ // governs type "chat".
52
+ export const OPENAI_COMPAT_CHAT_PROVIDERS: ReadonlySet<Provider> = new Set<Provider>([
53
+ "moonshotai",
54
+ "alibaba",
55
+ "deepseek",
56
+ "minimax",
57
+ ]);
41
58
 
42
59
  export interface ModelEntry {
43
60
  id: string;
@@ -62,6 +79,10 @@ export interface ModelEntry {
62
79
  // max_output_tokens }) for models that only ship that format (gpt-5.6-*,
63
80
  // gpt-5.5-pro). See src/providers/openai.ts.
64
81
  api?: "responses";
82
+ // prism#258: chat only. Integer micro-USD per 1M tokens, read from the model's
83
+ // Cloudflare page on pricing.priced_at. Absent = unpriced = cost_usd null.
84
+ // An ESTIMATE for display; see src/pricing.ts for its limits.
85
+ pricing?: ModelPricing;
65
86
  }
66
87
 
67
88
  export const MODELS: ModelEntry[] = [
@@ -74,25 +95,35 @@ export const MODELS: ModelEntry[] = [
74
95
  // catalog surface; the legacy AI Gateway anthropic allowlist is frozen and
75
96
  // forwards this id keyless (provider 401, surfaced as a 502). The binding
76
97
  // path injects credentials. Dispatch lives in src/providers/anthropic.ts.
77
- { id: "anthropic/claude-fable-5", label: "Claude Fable 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true },
78
- { id: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
98
+ // 2026-12 catalog refresh: Claude 5.x family. New CF Unified Billing ids use
99
+ // the dotted CF form (anthropic/claude-opus-5.5), so they need binding: true
100
+ // (the binding path passes the full CF id; the legacy path strips the prefix
101
+ // and sends Anthropic's native name).
102
+ { id: "anthropic/claude-fable-5.2", label: "Claude Fable 5.2 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(8000000, 40000000) },
103
+ { id: "anthropic/claude-opus-5.5", label: "Claude Opus 5.5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(4000000, 20000000) },
104
+ { id: "anthropic/claude-sonnet-5.5", label: "Claude Sonnet 5.5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(2000000, 10000000) },
105
+ { id: "anthropic/claude-haiku-5.5", label: "Claude Haiku 5.5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(100000, 500000, TIER_UNSTATED) },
106
+ { id: "anthropic/claude-fable-5", label: "Claude Fable 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(10000000, 50000000) },
107
+ { id: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(2000000, 10000000) },
79
108
  // v0.170.0: Claude Opus 5 (near-Fable intelligence, lower price). New CF
80
109
  // Unified Billing onboarding; binding path required (legacy allowlist frozen).
81
- { id: "anthropic/claude-opus-5", label: "Claude Opus 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true },
82
- { id: "anthropic/claude-opus-4-8", label: "Claude Opus 4.8 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
83
- { id: "anthropic/claude-opus-4-7", label: "Claude Opus 4.7 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
84
- { id: "anthropic/claude-opus-4-6", label: "Claude Opus 4.6 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
85
- { id: "anthropic/claude-sonnet-4-6", label: "Claude Sonnet 4.6 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
86
- { id: "anthropic/claude-haiku-4-5", label: "Claude Haiku 4.5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true },
110
+ { id: "anthropic/claude-opus-5", label: "Claude Opus 5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, binding: true, pricing: px(5000000, 25000000) },
111
+ { id: "anthropic/claude-opus-4-8", label: "Claude Opus 4.8 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(5000000, 25000000) },
112
+ { id: "anthropic/claude-opus-4-7", label: "Claude Opus 4.7 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(5000000, 25000000) },
113
+ { id: "anthropic/claude-opus-4-6", label: "Claude Opus 4.6 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(5000000, 25000000) },
114
+ { id: "anthropic/claude-sonnet-4-6", label: "Claude Sonnet 4.6 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(3000000, 15000000) },
115
+ { id: "anthropic/claude-haiku-4-5", label: "Claude Haiku 4.5 (Anthropic)", group: "Chat \u00b7 Anthropic", type: "chat", capabilities: ["vision"], provider: "anthropic", streaming: true, pricing: px(1000000, 5000000) },
87
116
 
88
117
  // xAI / Grok (Unified Billing via cf-aig-authorization, routed through AI Gateway)
89
118
  // v0.170.0: grok-4.5 re-added via env.AI.run binding (binding: true). CF docs
90
119
  // now list it on the Unified Billing catalog with working env.AI.run examples;
91
120
  // legacy gateway allowlist remains frozen for new ids.
92
- { id: "xai/grok-4.5", label: "Grok 4.5 (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, binding: true },
93
- { id: "xai/grok-4.3", label: "Grok 4.3 (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true },
94
- { id: "xai/grok-4.20-multi-agent-0309", label: "Grok 4.20 Multi-Agent (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true },
95
- { id: "xai/grok-4.20-0309-reasoning", label: "Grok 4.20 Reasoning (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true },
121
+ // 2026-12 refresh: grok-4.7 (Chat Completions on the CF catalog); binding path, as grok-4.5.
122
+ { id: "xai/grok-4.7", label: "Grok 4.7 (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, binding: true, pricing: px(2000000, 6000000, TIER_200K) },
123
+ { id: "xai/grok-4.5", label: "Grok 4.5 (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, binding: true, pricing: px(2000000, 6000000, TIER_200K) },
124
+ { id: "xai/grok-4.3", label: "Grok 4.3 (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, pricing: px(1250000, 2500000) },
125
+ { id: "xai/grok-4.20-multi-agent-0309", label: "Grok 4.20 Multi-Agent (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, pricing: px(2000000, 6000000) },
126
+ { id: "xai/grok-4.20-0309-reasoning", label: "Grok 4.20 Reasoning (xAI)", group: "Chat \u00b7 xAI", type: "chat", capabilities: ["vision"], provider: "xai", streaming: true, pricing: px(2000000, 6000000) },
96
127
  // blocked (v0.169.0): xai/grok-build-0.1 is absent from the new CF Unified
97
128
  // Billing catalog, and the legacy AI Gateway allowlist is frozen (forwards
98
129
  // unknown ids keyless -> provider 401). Re-add when
@@ -103,14 +134,24 @@ export const MODELS: ModelEntry[] = [
103
134
  // AI (@cf/moonshotai/*). Chat Completions via env.AI.run; stream reuses the
104
135
  // OpenAI-compatible SSE path (callOpenAIStream). Vision claimed upstream;
105
136
  // multimodal-in through the proxy is unsmoked, so caps stay empty like OpenAI.
106
- { id: "moonshotai/kimi-k3", label: "Kimi K3 (Moonshot, 1M ctx)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "moonshotai", streaming: true },
107
- { id: "@cf/moonshotai/kimi-k2.6", label: "Kimi K2.6 (1T)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true },
108
- { id: "@cf/moonshotai/kimi-k2.7-code", label: "Kimi K2.7 Code (1T, vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true },
109
- { id: "@cf/openai/gpt-oss-120b", label: "GPT-OSS 120B (reasoning)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], streaming: true },
110
- { id: "@cf/meta/llama-4-scout-17b-16e-instruct", label: "Llama 4 Scout (MoE, vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true },
111
- { id: "@cf/google/gemma-4-26b-a4b-it", label: "Gemma 4 26B (vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true },
137
+ { id: "moonshotai/kimi-k3", label: "Kimi K3 (Moonshot, 1M ctx)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "moonshotai", streaming: true, pricing: px(3000000, 15000000) },
138
+ { id: "moonshotai/kimi-k3.1-pro", label: "Kimi K3.1 Pro (Moonshot, 1M ctx)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "moonshotai", streaming: true, pricing: px(2000000, 10000000) },
139
+ // 2026-12 refresh: more Chat Completions providers on OPENAI_COMPAT_CHAT_PROVIDERS.
140
+ // Caps stay empty: multimodal-in through the proxy is unsmoked (K3 convention).
141
+ { id: "alibaba/qwen3.8-max", label: "Qwen 3.8 Max (Alibaba)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "alibaba", streaming: true, pricing: px(2000000, 6000000) },
142
+ { id: "deepseek/deepseek-v4-pro", label: "DeepSeek V4 Pro (DeepSeek)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "deepseek", streaming: true, pricing: px(1740000, 3480000) },
143
+ { id: "minimax/m3", label: "MiniMax M3 (1M ctx)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], provider: "minimax", streaming: true, pricing: px(300000, 1200000, TIER_512K) },
144
+ // 2026-12 refresh: Workers AI replacements CF recommends for the models it retired on
145
+ // 2026-11-20 (HTTP 410, error 5028): deepseek-v4.1-flash and glm-5.3 for
146
+ // frontier needs, qwen3.8-27b (and gemma-4, below) for smaller needs.
147
+ { id: "@cf/deepseek-ai/deepseek-v4.1-flash-1017", label: "DeepSeek V4.1 Flash (1M ctx, vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(300000, 1200000) },
148
+ { id: "@cf/zai-org/glm-5.3", label: "GLM-5.3 (Z.AI, agentic coding)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], streaming: true, pricing: px(1400000, 4400000) },
149
+ { id: "@cf/thinkingmachines/inkling-2-small", label: "Inkling 2 Small (Thinking Machines, vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(300000, 1000000) },
150
+ { id: "@cf/openai/gpt-oss-120b", label: "GPT-OSS 120B (reasoning)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: [], streaming: true, pricing: px(350000, 750000) },
151
+ { id: "@cf/meta/llama-4-scout-17b-16e-instruct", label: "Llama 4 Scout (MoE, vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(270000, 850000) },
152
+ { id: "@cf/google/gemma-4-26b-a4b-it", label: "Gemma 4 26B (vision)", group: "Chat \u00b7 Frontier", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(100000, 300000) },
112
153
  // OpenAI open weights
113
- { id: "@cf/openai/gpt-oss-20b", label: "GPT-OSS 20B", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], streaming: true },
154
+ { id: "@cf/openai/gpt-oss-20b", label: "GPT-OSS 20B", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], streaming: true, pricing: px(200000, 300000) },
114
155
  // OpenAI proxied via AI Gateway unified billing (v0.21.0; streaming added
115
156
  // v0.21.1). Routed through env.AI.run("openai/<model>", { messages }) on the
116
157
  // generic chat path; extractOutput handles both the chat-completions
@@ -120,45 +161,52 @@ export const MODELS: ModelEntry[] = [
120
161
  // against gpt-5.5 in v0.21.1, including token-usage on the final frame.
121
162
  // capabilities is empty: multimodal-in through the proxied binding is
122
163
  // unverified, so the attach affordance stays off.
123
- { id: "openai/gpt-5.5", label: "GPT-5.5 (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true },
164
+ { id: "openai/gpt-5.5", label: "GPT-5.5 (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(5000000, 30000000) },
165
+ // 2026-12 refresh: GPT-6 generation. The CF pages list Chat Completions and Responses,
166
+ // so the default Chat Completions path applies (no api flag).
167
+ { id: "openai/gpt-6.2-astra", label: "GPT-6.2 Astra (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(8000000, 40000000, TIER_UNSTATED) },
168
+ { id: "openai/gpt-6.2-sol", label: "GPT-6.2 Sol (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(2000000, 10000000, TIER_UNSTATED) },
169
+ { id: "openai/gpt-6.1-terra", label: "GPT-6.1 Terra (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(1000000, 5000000, TIER_UNSTATED) },
170
+ { id: "openai/gpt-6-luna", label: "GPT-6 Luna (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(100000, 500000, TIER_UNSTATED) },
124
171
  // v0.173.0: Responses API only (not Chat Completions). Flagged api:"responses".
125
- { id: "openai/gpt-5.5-pro", label: "GPT-5.5 Pro (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses" },
126
- { id: "openai/gpt-5.6-sol", label: "GPT-5.6 Sol (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses" },
127
- { id: "openai/gpt-5.6-terra", label: "GPT-5.6 Terra (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses" },
128
- { id: "openai/gpt-5.6-luna", label: "GPT-5.6 Luna (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses" },
129
- { id: "openai/gpt-5.4", label: "GPT-5.4 (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true },
130
- { id: "openai/gpt-5.4-mini", label: "GPT-5.4 mini (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true },
131
- { id: "openai/o4-mini", label: "o4-mini (OpenAI, reasoning)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true },
172
+ { id: "openai/gpt-5.5-pro", label: "GPT-5.5 Pro (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses", pricing: px(30000000, 180000000) },
173
+ { id: "openai/gpt-5.6-sol", label: "GPT-5.6 Sol (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses", pricing: px(5000000, 30000000, TIER_UNSTATED) },
174
+ { id: "openai/gpt-5.6-terra", label: "GPT-5.6 Terra (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses", pricing: px(2000000, 12000000, TIER_UNSTATED) },
175
+ { id: "openai/gpt-5.6-luna", label: "GPT-5.6 Luna (OpenAI, Responses)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, api: "responses", pricing: px(200000, 1200000, TIER_UNSTATED) },
176
+ { id: "openai/gpt-5.4", label: "GPT-5.4 (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(2500000, 15000000) },
177
+ { id: "openai/gpt-5.4-mini", label: "GPT-5.4 mini (OpenAI)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(750000, 4500000) },
178
+ { id: "openai/o4-mini", label: "o4-mini (OpenAI, reasoning)", group: "Chat \u00b7 OpenAI", type: "chat", capabilities: [], provider: "openai", streaming: true, pricing: px(1100000, 4400000) },
132
179
  // Meta
133
- { id: "@cf/meta/llama-3.3-70b-instruct-fp8-fast", label: "Llama 3.3 70B (fp8)", group: "Chat \u00b7 Meta", type: "chat", capabilities: [], streaming: true },
134
- { id: "@cf/meta/llama-3.2-11b-vision-instruct", label: "Llama 3.2 11B (vision)", group: "Chat \u00b7 Meta", type: "chat", capabilities: ["vision"], streaming: true },
135
- { id: "@cf/meta/llama-3.2-3b-instruct", label: "Llama 3.2 3B", group: "Chat \u00b7 Meta", type: "chat", capabilities: [], streaming: true },
180
+ { id: "@cf/meta/llama-3.3-70b-instruct-fp8-fast", label: "Llama 3.3 70B (fp8)", group: "Chat \u00b7 Meta", type: "chat", capabilities: [], streaming: true, pricing: px(293000, 2253000) },
181
+ { id: "@cf/meta/llama-3.2-11b-vision-instruct", label: "Llama 3.2 11B (vision)", group: "Chat \u00b7 Meta", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(48500, 676000) },
136
182
  // Qwen
137
- { id: "@cf/qwen/qwen3-30b-a3b-fp8", label: "Qwen3 30B MoE", group: "Chat \u00b7 Qwen", type: "chat", capabilities: [], streaming: true },
138
- { id: "@cf/qwen/qwq-32b", label: "QwQ 32B (reasoning)", group: "Chat \u00b7 Qwen", type: "chat", capabilities: [], streaming: true },
139
- { id: "@cf/qwen/qwen2.5-coder-32b-instruct", label: "Qwen2.5 Coder 32B", group: "Chat \u00b7 Qwen", type: "chat", capabilities: [], streaming: true },
183
+ { id: "@cf/qwen/qwen2.5-coder-32b-instruct", label: "Qwen2.5 Coder 32B", group: "Chat \u00b7 Qwen", type: "chat", capabilities: [], streaming: true, pricing: px(660000, 1000000) },
184
+ { id: "@cf/qwen/qwen3.8-27b", label: "Qwen 3.8 27B (vision)", group: "Chat \u00b7 Qwen", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(450000, 3200000) },
140
185
  // Other
141
- { id: "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", label: "DeepSeek R1 32B", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
142
- { id: "@cf/mistralai/mistral-small-3.1-24b-instruct", label: "Mistral Small 3.1 (vision)", group: "Chat \u00b7 Other", type: "chat", capabilities: ["vision"], streaming: true },
143
- { id: "@cf/zai-org/glm-4.7-flash", label: "GLM-4.7 Flash (Z.AI, 100+ lang)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
144
- { id: "@cf/zai-org/glm-5.2", label: "GLM-5.2 (Z.AI, agentic coding)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
145
- { id: "@cf/nvidia/nemotron-3-120b-a12b", label: "Nemotron 3 120B (NVIDIA, agentic)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
146
- { id: "@cf/aisingapore/gemma-sea-lion-v4-27b-it", label: "SEA-LION v4 27B (SE Asian langs)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
186
+ { id: "@cf/mistralai/mistral-small-3.1-24b-instruct", label: "Mistral Small 3.1 (vision)", group: "Chat \u00b7 Other", type: "chat", capabilities: ["vision"], streaming: true, pricing: px(351000, 555000) },
187
+ { id: "@cf/zai-org/glm-4.7-flash", label: "GLM-4.7 Flash (Z.AI, 100+ lang)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true, pricing: px(60500, 400000) },
188
+ { id: "@cf/aisingapore/gemma-sea-lion-v4-27b-it", label: "SEA-LION v4 27B (SE Asian langs)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true, pricing: px(351000, 555000) },
147
189
  // Gemini proxied via Unified Billing (v0.21.3; streaming v0.21.4). NOT
148
190
  // OpenAI-shaped: native contents/candidates format, transformed by
149
191
  // src/providers/google.ts. Streaming via callGeminiStream +
150
192
  // interpretGeminiSSEFrame, with a dual-mode delta reconciler (handles
151
193
  // incremental or cumulative chunks). Text-only (multimodal vision deferred).
152
- { id: "google/gemini-3.1-pro", label: "Gemini 3.1 Pro (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true },
153
- { id: "google/gemini-3.5-flash", label: "Gemini 3.5 Flash (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true },
194
+ { id: "google/gemini-3.1-pro", label: "Gemini 3.1 Pro (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(2000000, 12000000, TIER_200K) },
195
+ { id: "google/gemini-3.5-flash", label: "Gemini 3.5 Flash (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(1500000, 9000000) },
154
196
  // v0.170.0: newer Flash tier; same Generate Content / google dispatcher path.
155
- { id: "google/gemini-3.6-flash", label: "Gemini 3.6 Flash (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true },
197
+ { id: "google/gemini-3.6-flash", label: "Gemini 3.6 Flash (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(1500000, 7500000) },
198
+ // 2026-12 refresh: same native contents/candidates shape as 3.6 (verified on the CF
199
+ // model pages), so the google dispatcher covers them.
200
+ { id: "google/gemini-3.8-flash", label: "Gemini 3.8 Flash (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(750000, 3750000) },
201
+ { id: "google/gemini-4-argon", label: "Gemini 4 Argon (Google, frontier)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(4000000, 20000000) },
202
+ { id: "google/gemini-4-carbon", label: "Gemini 4 Carbon (Google, reasoning)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(4000000, 20000000) },
203
+ { id: "google/gemini-4-neon", label: "Gemini 4 Neon (Google)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(3000000, 15000000) },
204
+ { id: "google/gemini-4-hydrogen", label: "Gemini 4 Hydrogen (Google, fast)", group: "Chat \u00b7 Google", type: "chat", capabilities: [], provider: "google", streaming: true, pricing: px(1500000, 7500000) },
156
205
  // @cf/google/gemma-3-12b-it removed v0.165.0: marked Deprecated on the
157
206
  // Workers AI model list; gemma-4-26b-a4b-it (above) is the current Gemma.
158
- { id: "@cf/ibm-granite/granite-4.0-h-micro", label: "Granite 4.0 Micro (IBM)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true },
207
+ { id: "@cf/ibm-granite/granite-4.0-h-micro", label: "Granite 4.0 Micro (IBM)", group: "Chat \u00b7 Other", type: "chat", capabilities: [], streaming: true, pricing: px(17000, 112000) },
159
208
  // @hf/nousresearch/hermes-2-pro-mistral-7b removed v0.165.0: marked
160
209
  // Deprecated (and Beta) on the Workers AI model list.
161
- { id: "@cf/meta/llama-3.2-1b-instruct", label: "Llama 3.2 1B (tiny, cheap)", group: "Chat \u00b7 Meta", type: "chat", capabilities: [], streaming: true },
162
210
 
163
211
  // ---- Image generation ----
164
212
  // Google proxied (Unified Billing): URL-returning, different schema from the
@@ -169,6 +217,8 @@ export const MODELS: ModelEntry[] = [
169
217
  { id: "google/nano-banana-2", label: "Nano Banana 2 (Google)", group: "Image Gen", type: "image", capabilities: [], provider: "google" },
170
218
  // v0.172.0: fast/cheap Nano Banana sibling; same google proxied image path.
171
219
  { id: "google/nano-banana-2-lite", label: "Nano Banana 2 Lite (Google)", group: "Image Gen", type: "image", capabilities: [], provider: "google" },
220
+ // 2026-12 refresh: same { prompt, output_format: "png" } schema; google image path.
221
+ { id: "google/nano-banana-2.1", label: "Nano Banana 2.1 (Google)", group: "Image Gen", type: "image", capabilities: [], provider: "google" },
172
222
  { id: "google/imagen-4", label: "Imagen 4 (Google)", group: "Image Gen", type: "image", capabilities: [], provider: "google" },
173
223
  // gpt-image-1.5 (v0.22.0). Opaque on CF proxy by default ({ prompt, quality,
174
224
  // size }; proxy 7003-rejects background/output_format). Optional OPENAI_API_KEY
@@ -183,28 +233,31 @@ export const MODELS: ModelEntry[] = [
183
233
  // v0.172.0: standard-res V4.1 (pro is 2048px+); same recraft dispatcher.
184
234
  { id: "recraft/recraftv4-1", label: "Recraft V4.1 (art-directed, opaque)", group: "Image Gen", type: "image", capabilities: [], provider: "recraft" },
185
235
  { id: "recraft/recraftv4-1-pro", label: "Recraft V4.1 Pro (art-directed, opaque)", group: "Image Gen", type: "image", capabilities: [], provider: "recraft" },
236
+ // 2026-12 refresh: fast/cheap V4.1 raster; bare { prompt }, recraft path.
237
+ { id: "recraft/recraftv4-1-flash", label: "Recraft V4.1 Flash (fast, opaque)", group: "Image Gen", type: "image", capabilities: [], provider: "recraft" },
186
238
  // v0.171.0: xAI / ByteDance image via buildProxiedImageParams +
187
239
  // extractProxiedImageAsset. Seedream: result.images[]; Grok Imagine:
188
240
  // b64_json (ZDR) or URL, normalized by extractProxiedImageAsset.
189
241
  { id: "xai/grok-imagine-image", label: "Grok Imagine Image (xAI)", group: "Image Gen", type: "image", capabilities: [], provider: "xai" },
190
242
  // v0.172.0: higher-fidelity Grok Imagine sibling; same xai image path.
191
243
  { id: "xai/grok-imagine-image-quality", label: "Grok Imagine Image Quality (xAI)", group: "Image Gen", type: "image", capabilities: [], provider: "xai" },
244
+ // 2026-12 refresh: accepts response_format b64_json, as its siblings; xai image path.
245
+ { id: "xai/grok-imagine-image-2.0", label: "Grok Imagine Image 2.0 (xAI)", group: "Image Gen", type: "image", capabilities: [], provider: "xai" },
192
246
  { id: "bytedance/seedream-5-pro", label: "Seedream 5 Pro (ByteDance)", group: "Image Gen", type: "image", capabilities: [], provider: "bytedance" },
193
247
  // v0.172.0: lighter/faster Seedream; same bytedance image path (images[]).
194
248
  { id: "bytedance/seedream-5-lite", label: "Seedream 5 Lite (ByteDance)", group: "Image Gen", type: "image", capabilities: [], provider: "bytedance" },
249
+ // 2026-12 refresh: same bare { prompt } shape; bytedance image path.
250
+ { id: "bytedance/seedream-5.5", label: "Seedream 5.5 (ByteDance)", group: "Image Gen", type: "image", capabilities: [], provider: "bytedance" },
195
251
  { id: "@cf/black-forest-labs/flux-2-klein-9b", label: "FLUX 2 Klein 9B (frontier)", group: "Image Gen", type: "image", capabilities: [] },
196
252
  { id: "@cf/black-forest-labs/flux-2-klein-4b", label: "FLUX 2 Klein 4B (faster)", group: "Image Gen", type: "image", capabilities: [] },
197
253
  { id: "@cf/black-forest-labs/flux-2-dev", label: "FLUX 2 Dev (multi-reference)", group: "Image Gen", type: "image", capabilities: [] },
198
254
  { id: "@cf/black-forest-labs/flux-1-schnell", label: "FLUX-1 schnell (fast)", group: "Image Gen", type: "image", capabilities: [] },
199
255
  { id: "@cf/leonardo/lucid-origin", label: "Lucid Origin (Leonardo)", group: "Image Gen", type: "image", capabilities: [] },
200
256
  { id: "@cf/leonardo/phoenix-1.0", label: "Phoenix 1.0 (Leonardo)", group: "Image Gen", type: "image", capabilities: [] },
201
- { id: "@cf/lykon/dreamshaper-8-lcm", label: "Dreamshaper 8 LCM (fast SD)", group: "Image Gen", type: "image", capabilities: [] },
202
- { id: "@cf/stabilityai/stable-diffusion-xl-base-1.0", label: "Stable Diffusion XL (SDXL)", group: "Image Gen", type: "image", capabilities: [] },
203
257
 
204
258
  // ---- Text-to-speech ----
205
259
  { id: "@cf/deepgram/aura-2-en", label: "Aura-2 English (Deepgram)", group: "TTS", type: "tts", capabilities: [] },
206
260
  { id: "@cf/deepgram/aura-2-es", label: "Aura-2 Spanish (Deepgram)", group: "TTS", type: "tts", capabilities: [] },
207
- { id: "@cf/myshell-ai/melotts", label: "MeloTTS (multilingual)", group: "TTS", type: "tts", capabilities: [] },
208
261
 
209
262
  // ---- Speech-to-text ----
210
263
  // Attach an audio file, pick a model, get the transcript. Audio file is
@@ -212,7 +265,6 @@ export const MODELS: ModelEntry[] = [
212
265
  // Deepgram have different input/output contracts; runStt adapts per model.
213
266
  { id: "@cf/openai/whisper-large-v3-turbo", label: "Whisper Large v3 Turbo (best)", group: "Speech-to-text", type: "stt", capabilities: [] },
214
267
  { id: "@cf/openai/whisper", label: "Whisper (general purpose)", group: "Speech-to-text", type: "stt", capabilities: [] },
215
- { id: "@cf/openai/whisper-tiny-en", label: "Whisper Tiny EN (fast, beta)", group: "Speech-to-text", type: "stt", capabilities: [] },
216
268
  { id: "@cf/deepgram/nova-3", label: "Deepgram Nova-3 (accurate)", group: "Speech-to-text", type: "stt", capabilities: [] },
217
269
  // @cf/deepgram/flux is websocket-only (error 8006 over the request/response
218
270
  // binding), so it is NOT a one-shot "stt" model. It is a live "voice" session:
@@ -230,6 +282,9 @@ export const MODELS: ModelEntry[] = [
230
282
  { id: "google/veo-3.1-fast", label: "Veo 3.1 Fast (Google)", group: "Video Gen", type: "video", capabilities: [], provider: "google" },
231
283
  // google/veo-3 and google/veo-3-fast: CF returns 7010 deprecated
232
284
  // ("use google/veo-3.1-fast instead"); removed from catalog 2026-08-04.
285
+ // 2026-12 refresh: Seedance 2.5 shares the 2.0 i2v schema (image, integer duration,
286
+ // resolution, aspect_ratio, fps 24); see imageToVideoParams.
287
+ { id: "bytedance/seedance-2.5", label: "Seedance 2.5 (ByteDance)", group: "Video Gen", type: "video", capabilities: ["image-input"], provider: "bytedance" },
233
288
  { id: "bytedance/seedance-2.0", label: "Seedance 2.0 (ByteDance)", group: "Video Gen", type: "video", capabilities: ["image-input"], provider: "bytedance" },
234
289
  { id: "bytedance/seedance-2.0-fast", label: "Seedance 2.0 Fast (ByteDance)", group: "Video Gen", type: "video", capabilities: ["image-input"], provider: "bytedance" },
235
290
  // v0.170.0: compact/cost-efficient Seedance sibling; same t2v/i2v param shape.
@@ -10,7 +10,7 @@
10
10
  // emit `input_tokens`/`output_tokens`. We accept both and prefer the OpenAI
11
11
  // names when both are present.
12
12
  //
13
- // Reasoning models (gpt-oss-120b, qwq-32b, deepseek-r1-distill-qwen-32b)
13
+ // Reasoning models (for example gpt-oss-120b)
14
14
  // emit `<think>...</think>` blocks inside `response`. The interpreter passes
15
15
  // them through unchanged; the UI is responsible for folding them if desired.
16
16
 
@@ -0,0 +1,128 @@
1
+ // Chat cost estimate (prism#258, Part of prism#251 Sprint 1).
2
+ //
3
+ // DISPLAY ONLY. cost_usd is never an input to a limit, a charge, or a quota.
4
+ // It is an ESTIMATE of what a chat turn cost at the model's published list
5
+ // rate, not a bill:
6
+ // - Rates are copied by hand from each model's Cloudflare model page and go
7
+ // stale. `priced_at` on every entry says when they were read.
8
+ // - The cached-input rate is NOT applied: no stream parser reads a cached
9
+ // token count yet, so every input token is priced at the full input rate.
10
+ // - Gemini thinking tokens are left out of the output count upstream
11
+ // (src/output-extract.ts), so a thinking turn is under-counted.
12
+ // - Some models have a long-context tier. Only the base tier is priced, and
13
+ // only when the prompt is at or under `max_in_tokens`; above it the cost
14
+ // is null (unknown), never a base-tier guess.
15
+ // - On the control-plane path the plane's own charge is used instead (see
16
+ // planeCostUsd). In BYOK mode the user's Cloudflare bill is the truth.
17
+ //
18
+ // Rates are INTEGER micro-USD per 1M tokens ($1.00 per 1M = 1_000_000). Cost is
19
+ // integer math with ONE rounding step, UP on the total (as the plane does,
20
+ // prism-control-plane src/meter.ts), done in BigInt so no float is ever in the
21
+ // arithmetic. The result is converted to USD once, by a single division.
22
+ //
23
+ // Null is not zero. Zero means free and exists only for a real zero rate. An
24
+ // unpriced model, a missing or unsafe token count, a non-chat row and a failed
25
+ // row all give null.
26
+
27
+ /** Date the rates in src/models.ts were read from the Cloudflare model pages. */
28
+ export const PRICED_AT = "2026-12-04";
29
+
30
+ /** Largest token count on either side that we will price (10M). Above it: null. */
31
+ export const MAX_PRICED_TOKENS = 10_000_000;
32
+
33
+ /** Largest plane charge we will show, micro-USD ($1000). Above it: null. */
34
+ export const MAX_PLANE_MICRO_USD = 1_000_000_000;
35
+
36
+ /** Base-tier ceilings for models with a long-context tier. */
37
+ export const TIER_200K = 200_000;
38
+ export const TIER_512K = 512_000;
39
+ /** The model page names a short and a long tier but not the boundary: price only below a conservative 128k. */
40
+ export const TIER_UNSTATED = 128_000;
41
+
42
+ export interface ModelPricing {
43
+ /** Input rate, integer micro-USD per 1M tokens. */
44
+ in_micro_per_mtok: number;
45
+ /** Output rate, integer micro-USD per 1M tokens. */
46
+ out_micro_per_mtok: number;
47
+ /** Date the rate was read from the model page (YYYY-MM-DD). */
48
+ priced_at: string;
49
+ /** Base tier only: when the prompt has more tokens than this, cost is null. */
50
+ max_in_tokens?: number;
51
+ }
52
+
53
+ /** Catalog helper: integer micro-USD per 1M tokens, stamped with PRICED_AT. */
54
+ export function px(inMicro: number, outMicro: number, maxInTokens?: number): ModelPricing {
55
+ const p: ModelPricing = { in_micro_per_mtok: inMicro, out_micro_per_mtok: outMicro, priced_at: PRICED_AT };
56
+ if (maxInTokens !== undefined) p.max_in_tokens = maxInTokens;
57
+ return p;
58
+ }
59
+
60
+ function isCount(n: unknown): n is number {
61
+ return typeof n === "number" && Number.isSafeInteger(n) && n >= 0 && n <= MAX_PRICED_TOKENS;
62
+ }
63
+
64
+ function isRate(n: unknown): n is number {
65
+ return typeof n === "number" && Number.isSafeInteger(n) && n >= 0;
66
+ }
67
+
68
+ /**
69
+ * Cost in integer micro-USD, or null when it cannot be priced honestly.
70
+ * Both counts must be safe non-negative integers at or under MAX_PRICED_TOKENS.
71
+ */
72
+ export function costMicroUsd(
73
+ pricing: ModelPricing | undefined,
74
+ tokensIn: unknown,
75
+ tokensOut: unknown,
76
+ ): number | null {
77
+ if (!pricing) return null;
78
+ if (!isCount(tokensIn) || !isCount(tokensOut)) return null;
79
+ if (!isRate(pricing.in_micro_per_mtok) || !isRate(pricing.out_micro_per_mtok)) return null;
80
+ if (pricing.max_in_tokens !== undefined && tokensIn > pricing.max_in_tokens) return null;
81
+ const total =
82
+ BigInt(tokensIn) * BigInt(pricing.in_micro_per_mtok) +
83
+ BigInt(tokensOut) * BigInt(pricing.out_micro_per_mtok);
84
+ const micro = (total + 999_999n) / 1_000_000n; // one rounding step, up
85
+ return Number(micro);
86
+ }
87
+
88
+ /** Integer micro-USD to USD: one division, so the value prints as a clean 6-decimal figure. */
89
+ export function microToUsd(micro: number): number {
90
+ return micro / 1_000_000;
91
+ }
92
+
93
+ /**
94
+ * Catalog-priced USD for a chat turn, or null. Never throws: a pricing error
95
+ * must not fail the chat write, so any fault becomes null.
96
+ */
97
+ export function chatCostUsd(
98
+ pricing: ModelPricing | undefined,
99
+ tokensIn: unknown,
100
+ tokensOut: unknown,
101
+ ): number | null {
102
+ try {
103
+ const micro = costMicroUsd(pricing, tokensIn, tokensOut);
104
+ return micro === null ? null : microToUsd(micro);
105
+ } catch {
106
+ return null;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Control-plane path: the plane already charged the user and says how much in
112
+ * `prism-usage-micro-usd`, with `prism-metered: true`. That figure is the cost.
113
+ * If the plane did not meter the request, or the header is absent or malformed,
114
+ * the cost is null. Never the playground list price: operator overrides,
115
+ * rounding and later reconcile make the two differ.
116
+ */
117
+ export function planeCostUsd(headers: Headers): number | null {
118
+ try {
119
+ if ((headers.get("prism-metered") ?? "").trim().toLowerCase() !== "true") return null;
120
+ const raw = (headers.get("prism-usage-micro-usd") ?? "").trim();
121
+ if (!/^\d{1,10}$/.test(raw)) return null;
122
+ const micro = Number(raw);
123
+ if (!Number.isSafeInteger(micro) || micro > MAX_PLANE_MICRO_USD) return null;
124
+ return microToUsd(micro);
125
+ } catch {
126
+ return null;
127
+ }
128
+ }