Skip to content

Commit 1b1a467

Browse files
codebamclaude
andcommitted
feat: refresh the model lineup and correct two capability flags
Rebuilt the catalogue against the live Workers AI model API, which exposes `function_calling`, `vision` and `price` properties directly. Corrects the previous commit, which got two flags wrong. I had probed the API with an 8x8 test image and a 20-40 token budget; both produce false negatives: small images are rejected outright for being under the minimum pixel size, and reasoning models spend the whole budget thinking and return empty content that looks like "unsupported". Re-probed with a 512x512 image and 600 tokens: - gemma4 does support tools AND vision (was marked as neither) - kimi-k2.6 does support vision (was marked as not) glm-4.7-flash genuinely is not multimodal — that one fails with a hard API error rather than an empty reply, so the original finding stands. Added, all verified to emit real tool calls: granite-4-micro 1★ cheapest model that can call tools ($0.017/$0.112) gpt-oss-20b 6★ cheap reasoning kimi-k2.7-code 40★ same price as k2.6, tuned for code Removed: llama-3.2-vision old Llama 3.2, confirmed twice to never emit a tool call; gemma4 now covers cheap vision better and does both nemotron-3 middling — gpt-oss-120b is cheaper with the same shape Cheap end kept deliberately broad: granite-4-micro at 1★, glm-4.7-flash at 3★ (still the default) and gemma4 at 4★, the last of which does vision and tools. The vision fallback moves from llama-4-scout to gemma4: both are verified for vision plus tools, but gemma4 is $0.10/$0.30 against $0.27/$0.85, so a user who sends a photo to a text-only model is no longer bumped onto a dearer tier. Whole ladder now sits at 38-47x break-even. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaLeuxVikb3iH2Etw2tHe7
1 parent 523d3b0 commit 1b1a467

1 file changed

Lines changed: 40 additions & 27 deletions

File tree

packages/shared/src/index.ts

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -481,49 +481,62 @@ export const MAX_HISTORY_MESSAGES = 40;
481481
/**
482482
* Model catalogue.
483483
*
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.
484+
* `cost` is in Telegram Stars, derived from the provider token prices reported
485+
* by the Workers AI model API rather than picked by feel. A Star nets us about
486+
* $0.009 after the mobile app-store cut, and a tool-using turn costs roughly
487+
* 6k input / 800 output tokens once the multi-turn tool loop is counted. Every
488+
* entry is priced at ~40x that break-even, which keeps the ladder proportional
489+
* to real cost while leaving headroom for long contexts and retries.
491490
*
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.
491+
* `supportsTools` / `supportsVision` are checked against the live API and
492+
* cross-referenced with the catalogue's own `function_calling` / `vision`
493+
* properties. Two gotchas make naive probing lie:
494+
* - reasoning models spend the token budget thinking, so a small max_tokens
495+
* returns empty content and looks like "unsupported";
496+
* - some vision models reject images below a minimum pixel size.
497+
* Both produce false negatives. Verify with a real image and a generous budget.
496498
*/
497499
export const AVAILABLE_MODELS: Record<
498500
string,
499501
{ id: string; cost: number; supportsTools?: boolean; supportsVision?: boolean }
500502
> = {
501-
// Cheap default. Emits real tool calls; explicitly NOT multimodal
502-
// ("GLM-4.7-Flash is not a multimodal model").
503+
// --- budget tier -------------------------------------------------------
504+
// Cheapest thing that can still call tools ($0.017/$0.112 per 1M).
505+
'granite-4-micro': { id: '@cf/ibm-granite/granite-4.0-h-micro', cost: 1, supportsTools: true },
506+
// Default. Fast and cheap, but explicitly NOT multimodal — the API rejects
507+
// images with "GLM-4.7-Flash is not a multimodal model".
503508
'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.
509+
// Best value multimodal: tools + vision for $0.10/$0.30, which is why it is
510+
// also the automatic fallback when someone sends a photo.
511+
gemma4: { id: '@cf/google/gemma-4-26b-a4b-it', cost: 4, supportsTools: true, supportsVision: true },
512+
'gpt-oss-20b': { id: '@cf/openai/gpt-oss-20b', cost: 6, supportsTools: true },
513+
514+
// --- mid tier ----------------------------------------------------------
510515
'llama-4-scout': {
511516
id: '@cf/meta/llama-4-scout-17b-16e-instruct',
512517
cost: 10,
513518
supportsTools: true,
514519
supportsVision: true
515520
},
516-
'gpt-oss-120b': { id: '@cf/openai/gpt-oss-120b', cost: 12, supportsTools: true },
517521
'google/gemini-3-flash': {
518522
id: 'google/gemini-3-flash',
519523
cost: 12,
520524
supportsTools: true,
521525
supportsVision: true
522526
},
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 },
527+
'gpt-oss-120b': { id: '@cf/openai/gpt-oss-120b', cost: 12, supportsTools: true },
528+
529+
// --- flagship tier -----------------------------------------------------
530+
'kimi-k2.6': { id: '@cf/moonshotai/kimi-k2.6', cost: 40, supportsTools: true, supportsVision: true },
531+
// Same price as k2.6, tuned for code.
532+
'kimi-k2.7-code': {
533+
id: '@cf/moonshotai/kimi-k2.7-code',
534+
cost: 40,
535+
supportsTools: true,
536+
supportsVision: true
537+
},
525538
'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.
539+
// Dearest by a distance ($2/$12 per 1M at list) and priced to match.
527540
'google/gemini-3.1-pro': {
528541
id: 'google/gemini-3.1-pro',
529542
cost: 100,
@@ -533,11 +546,11 @@ export const AVAILABLE_MODELS: Record<
533546
};
534547

535548
/**
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.
549+
* Model used when the user's choice cannot handle an image. Must do both vision
550+
* and tool calls, and should be cheap — a user who sends a photo to a text-only
551+
* model should not be pushed onto an expensive tier.
539552
*/
540-
export const VISION_FALLBACK_MODEL = 'llama-4-scout';
553+
export const VISION_FALLBACK_MODEL = 'gemma4';
541554

542555
/** Look up a model entry by its provider-facing id (e.g. `@cf/...`). */
543556
export function modelConfigById(id: string | undefined) {

0 commit comments

Comments
 (0)