Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

models.ts

47 lines1.3 KB

1import type {
2 AiModels,
3 BaseAiAutomaticSpeechRecognition,
4 BaseAiTextEmbeddings,
5 BaseAiTextGeneration,
6 BaseAiTextToImage,
7 BaseAiTextToSpeech,
8} from '@cloudflare/workers-types'
9​
10/** Model ids from the Workers AI catalog whose task shape matches `TTask`. */
11type ModelsFor<TTask> = {
12 [K in keyof AiModels]: AiModels[K] extends TTask ? K : never
13}[keyof AiModels]
14​
15/**
16 * Chat model id. Catalog ids get autocomplete; any other id works too,
17 * including third-party `provider/model` ids routed through AI Gateway
18 * (for example `openai/gpt-5.5`).
19 */
20export type CloudflareTextModel =
21 | ModelsFor<BaseAiTextGeneration>
22 | (string & {})
23​
24export type CloudflareEmbeddingModel =
25 | ModelsFor<BaseAiTextEmbeddings>
26 | (string & {})
27​
28export type CloudflareImageModel = ModelsFor<BaseAiTextToImage> | (string & {})
29​
30export type CloudflareTTSModel =
31 | ModelsFor<BaseAiTextToSpeech>
32 | '@cf/deepgram/aura-1'
33 | '@cf/deepgram/aura-2-en'
34 | '@cf/deepgram/aura-2-es'
35 | (string & {})
36​
37export type CloudflareTranscriptionModel =
38 | ModelsFor<BaseAiAutomaticSpeechRecognition>
39 | '@cf/openai/whisper-large-v3-turbo'
40 | '@cf/deepgram/nova-3'
41 | (string & {})
42​
43/**
44 * Evaluate model id. TypeSafe Jev on Workers AI is `typesafe/jev`.
45 * Any other id works too.
46 */
47export type CloudflareEvaluateModel = 'typesafe/jev' | (string & {})