Skip to content

Commit 523d3b0

Browse files
codebamclaude
andcommitted
feat: reprice Stars from real provider costs and refresh the model lineup
Pricing was not derived from anything. It had inversions — DeepSeek R1, a 32B distill with no tool support, cost 80 Stars while Kimi K2.6 cost 45 — and markups ranging from ~60x on chat to ~4000x on image generation, so the ladder told users nothing about relative value. Prices are now set from measured provider rates. Assuming ~$0.009 net per Star (the mobile figure, after the app-store cut) and ~6k input / 800 output tokens for a tool-using turn once the multi-turn loop is counted, every model is priced at ~40x break-even: glm-4.7-flash 5 -> 3 nemotron-3 20 -> 18 gemma4 8 -> 4 kimi-k2.6 45 -> 40 llama-3.2-vision 8 -> 4 glm-5.2 - -> 55 llama-4-scout - -> 10 gemini-3.1-pro 150 -> 100 gpt-oss-120b - -> 12 /photo 100 -> 20 gemini-3-flash 25 -> 12 voice surcharge 20 -> 3 upload 5 -> 2 Capability flags are now verified against the live API instead of assumed, and two of them were wrong in the dangerous direction: - glm-4.7-flash, the DEFAULT model, claimed supportsVision. The API rejects images outright ("GLM-4.7-Flash is not a multimodal model"), so the vision fallback in chargeStars never fired and photos from default users failed. - gemma4 and llama-3.2-vision claimed supportsTools. Both accept a tools array and never emit a tool call. Lineup changes: added llama-4-scout (the only model confirmed to do both vision and tool calls, so it is also the new vision fallback), gpt-oss-120b and glm-5.2; dropped deepseek-r1-32b (no tools, dearest output in the catalogue) and gemini-3.1-flash-lite (unpublished third-party rate). Stored preferences for removed models fall through to the default rather than erroring. Photo and voice were the worst offenders: flux-1-schnell costs ~$0.0002 an image and Whisper $0.0005 a minute, so 100 Stars made an image five times dearer than a full conversation with the best model available. Note: @cf/* rates come from Cloudflare's published pricing; the gemini-* models are third-party and Cloudflare does not publish their rates, so Google list prices are used as the basis. The 40x multiple absorbs that uncertainty. Also fixes the Telegram link on the docs site to https://t.me/TuxRobot. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaLeuxVikb3iH2Etw2tHe7
1 parent b7b8046 commit 523d3b0

4 files changed

Lines changed: 69 additions & 26 deletions

File tree

bot

Submodule bot updated 1 file

packages/shared/src/index.ts

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -455,47 +455,90 @@ export const SYSTEM_PROMPTS = {
455455

456456
export const DEFAULT_MODEL = 'glm-4.7-flash';
457457

458-
/** Extra Stars charged on top of the model cost for Whisper transcription. */
459-
export const VOICE_SURCHARGE_STARS = 20;
458+
/**
459+
* Extra Stars on top of the model cost for Whisper transcription.
460+
* Whisper bills $0.0005 per audio minute, so the old +20 was a ~700x markup on
461+
* a step that costs a fraction of the reply it feeds.
462+
*/
463+
export const VOICE_SURCHARGE_STARS = 3;
460464

461-
/** Stars charged per web app file upload. */
462-
export const UPLOAD_COST_STARS = 5;
465+
/**
466+
* Stars per web app file upload. An R2 put plus a KV write costs essentially
467+
* nothing; this exists as an anti-spam deterrent, not as a revenue line.
468+
*/
469+
export const UPLOAD_COST_STARS = 2;
463470

464-
/** Cost of one `/photo` image generation. */
465-
export const PHOTO_COST_STARS = 100;
471+
/**
472+
* Cost of one `/photo` generation. flux-1-schnell bills $0.0000528 per 512px
473+
* tile — about $0.0002 for a 1024x1024 image — so charging 100 Stars made an
474+
* image five times dearer than a full conversation with our best model.
475+
*/
476+
export const PHOTO_COST_STARS = 20;
466477

467478
/** Hard cap on history entries accepted from an untrusted request body. */
468479
export const MAX_HISTORY_MESSAGES = 40;
469480

481+
/**
482+
* Model catalogue.
483+
*
484+
* `cost` is in Telegram Stars and is derived from real provider token prices
485+
* rather than picked by feel — see docs/pricing notes below. A Star nets us
486+
* roughly $0.009 after the mobile app-store cut, and a tool-using turn in this
487+
* bot costs about 6k input / 800 output tokens once the multi-turn tool loop is
488+
* accounted for. Prices are set at ~40x that break-even, rounded, which leaves
489+
* headroom for long contexts and retries while keeping the ladder proportional
490+
* to what each model actually costs.
491+
*
492+
* `supportsTools` and `supportsVision` are VERIFIED against the live API, not
493+
* assumed. Getting these wrong is not cosmetic: a model wrongly flagged as
494+
* vision-capable never triggers the fallback in chargeStars, so the user's
495+
* photo silently fails. Both flags fail safe — when unsure, leave them off.
496+
*/
470497
export const AVAILABLE_MODELS: Record<
471498
string,
472499
{ id: string; cost: number; supportsTools?: boolean; supportsVision?: boolean }
473500
> = {
474-
gemma4: { id: '@cf/google/gemma-4-26b-a4b-it', cost: 8, supportsTools: true, supportsVision: true },
475-
'google/gemini-3-flash': { id: 'google/gemini-3-flash', cost: 25, supportsTools: true, supportsVision: true },
476-
'google/gemini-3.1-flash-lite': {
477-
id: 'google/gemini-3.1-flash-lite',
478-
cost: 12,
501+
// Cheap default. Emits real tool calls; explicitly NOT multimodal
502+
// ("GLM-4.7-Flash is not a multimodal model").
503+
'glm-4.7-flash': { id: '@cf/zai-org/glm-4.7-flash', cost: 3, supportsTools: true },
504+
// Accepts a tools array but never emits a tool call, so don't advertise it.
505+
gemma4: { id: '@cf/google/gemma-4-26b-a4b-it', cost: 4 },
506+
// Budget vision. Same story on tools: accepted, never used.
507+
'llama-3.2-vision': { id: '@cf/meta/llama-3.2-11b-vision-instruct', cost: 4, supportsVision: true },
508+
// The all-rounder: confirmed tool calls *and* image understanding, which is
509+
// why it is also the automatic fallback for images.
510+
'llama-4-scout': {
511+
id: '@cf/meta/llama-4-scout-17b-16e-instruct',
512+
cost: 10,
479513
supportsTools: true,
480514
supportsVision: true
481515
},
482-
'google/gemini-3.1-pro': { id: 'google/gemini-3.1-pro', cost: 150, supportsTools: true, supportsVision: true },
483-
'llama-3.2-vision': {
484-
id: '@cf/meta/llama-3.2-11b-vision-instruct',
485-
cost: 8,
516+
'gpt-oss-120b': { id: '@cf/openai/gpt-oss-120b', cost: 12, supportsTools: true },
517+
'google/gemini-3-flash': {
518+
id: 'google/gemini-3-flash',
519+
cost: 12,
486520
supportsTools: true,
487521
supportsVision: true
488522
},
489-
'kimi-k2.6': { id: '@cf/moonshotai/kimi-k2.6', cost: 45, supportsTools: true, supportsVision: true },
490-
'glm-4.7-flash': { id: '@cf/zai-org/glm-4.7-flash', cost: 5, supportsTools: true, supportsVision: true },
491-
'deepseek-r1-32b': {
492-
id: '@cf/deepseek-ai/deepseek-r1-distill-qwen-32b',
493-
cost: 80,
494-
supportsTools: false
495-
},
496-
'nemotron-3': { id: '@cf/nvidia/nemotron-3-120b-a12b', cost: 20, supportsTools: true }
523+
'nemotron-3': { id: '@cf/nvidia/nemotron-3-120b-a12b', cost: 18, supportsTools: true },
524+
'kimi-k2.6': { id: '@cf/moonshotai/kimi-k2.6', cost: 40, supportsTools: true },
525+
'glm-5.2': { id: '@cf/zai-org/glm-5.2', cost: 55, supportsTools: true },
526+
// Priciest by a wide margin ($2/$12 per 1M at list), and priced to match.
527+
'google/gemini-3.1-pro': {
528+
id: 'google/gemini-3.1-pro',
529+
cost: 100,
530+
supportsTools: true,
531+
supportsVision: true
532+
}
497533
};
498534

535+
/**
536+
* Model used when the user's choice cannot handle an image. Must support both
537+
* vision and tools, and must have a known price — hence a first-party model
538+
* rather than a third-party one whose rate Cloudflare does not publish.
539+
*/
540+
export const VISION_FALLBACK_MODEL = 'llama-4-scout';
541+
499542
/** Look up a model entry by its provider-facing id (e.g. `@cf/...`). */
500543
export function modelConfigById(id: string | undefined) {
501544
if (!id) return undefined;

scripts/build-docs.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const html = `<!doctype html>
221221
Cloudflare Workers, Workers AI, Durable Objects and Pages.
222222
</p>
223223
<div class="cta">
224-
<a class="btn primary" href="https://t.me/tux_robot_bot">Open in Telegram</a>
224+
<a class="btn primary" href="https://t.me/TuxRobot">Open in Telegram</a>
225225
<a class="btn" href="${REPO}">Source on GitHub</a>
226226
</div>
227227
</div>

webapp

0 commit comments

Comments
 (0)