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

model-meta.ts

255 lines7.7 KB

1import type { ModelReasoning } from '@tanstack/ai'
2import type { ModelReasoningCapability } from '@tanstack/ai/adapter-internals'
3import type { LovableEmbeddingProviderOptions } from './embedding/embedding-provider-options'
4import type {
5 LovableImageProviderOptions,
6 LovableImageSize,
7} from './image/image-provider-options'
8import type { LovableTextProviderOptions } from './text/text-provider-options'
9import type {
10 LovableHdVideoSize,
11 LovableVideoDuration,
12 LovableVideoProviderOptions,
13 LovableVideoSize,
14} from './video/video-provider-options'
15​
16// Reasoning shapes: the levels a model has for `chat({ reasoning })`, and
17// the provider value to send for each. Each model points at one of them.
18const BUDGET_MINIMAL_TO_HIGH = {
19 levels: { minimal: 'minimal', low: 'low', medium: 'medium', high: 'high' },
20 budget: true,
21} as const
22const BUDGET_OFF_HIGH = {
23 levels: { off: 'off', high: 'high' },
24 budget: true,
25} as const
26const EFFORT_LOW_TO_HIGH = {
27 levels: { low: 'low', medium: 'medium', high: 'high' },
28 budget: false,
29} as const
30const EFFORT_MEDIUM_TO_XHIGH = {
31 levels: { medium: 'medium', high: 'high', xhigh: 'xhigh' },
32 budget: false,
33} as const
34const EFFORT_MINIMAL_TO_HIGH = {
35 levels: { minimal: 'minimal', low: 'low', medium: 'medium', high: 'high' },
36 budget: false,
37} as const
38const EFFORT_NONE_LOW_TO_MAX = {
39 levels: {
40 off: 'none',
41 low: 'low',
42 medium: 'medium',
43 high: 'high',
44 xhigh: 'xhigh',
45 max: 'max',
46 },
47 budget: false,
48} as const
49const EFFORT_NONE_LOW_TO_XHIGH = {
50 levels: {
51 off: 'none',
52 low: 'low',
53 medium: 'medium',
54 high: 'high',
55 xhigh: 'xhigh',
56 },
57 budget: false,
58} as const
59​
60/**
61 * Chat models listed on https://docs.lovable.dev/features/ai.
62 * Ids use the `google/` and `openai/` form that the gateway accepts.
63 */
64export const LOVABLE_CHAT_MODELS = [
65 'google/gemini-3.7-flash',
66 'google/gemini-3.6-flash',
67 'google/gemini-3.5-flash',
68 'google/gemini-3.1-pro-preview',
69 'google/gemini-3.1-flash-lite',
70 'google/gemini-3-flash-preview',
71 'google/gemini-2.5-pro',
72 'google/gemini-2.5-flash',
73 'google/gemini-2.5-flash-lite',
74 'openai/gpt-5.6-sol',
75 'openai/gpt-5.6-terra',
76 'openai/gpt-5.6-luna',
77 'openai/gpt-5.5-pro',
78 'openai/gpt-5.5',
79 'openai/gpt-5.4-pro',
80 'openai/gpt-5.4',
81 'openai/gpt-5.4-mini',
82 'openai/gpt-5.4-nano',
83 'openai/gpt-5.2',
84 'openai/gpt-5',
85 'openai/gpt-5-mini',
86 'openai/gpt-5-nano',
87] as const
88​
89export type LovableChatModel = (typeof LOVABLE_CHAT_MODELS)[number]
90​
91/**
92 * A curated chat model id from `LOVABLE_CHAT_MODELS`.
93 */
94export type LovableModelId = LovableChatModel
95​
96export type LovableChatModelProviderOptionsByName = {
97 [K in LovableChatModel]: LovableTextProviderOptions
99​
100export type LovableModelInputModalitiesByName = {
101 [K in LovableChatModel]: readonly ['text', 'image']
103​
104export type LovableChatModelToolCapabilitiesByName = {
105 [K in LovableChatModel]: readonly []
107​
108export type ResolveProviderOptions<TModel extends string> =
109 TModel extends keyof LovableChatModelProviderOptionsByName
110 ? LovableChatModelProviderOptionsByName[TModel]
111 : LovableTextProviderOptions
112​
113export type ResolveInputModalities<TModel extends string> =
114 TModel extends keyof LovableModelInputModalitiesByName
115 ? LovableModelInputModalitiesByName[TModel]
116 : readonly ['text']
117​
118export const LOVABLE_IMAGE_MODELS = [
119 'openai/gpt-image-2',
120 'openai/gpt-image-1-mini',
121 'google/gemini-3.1-flash-image',
122 'google/gemini-3.1-flash-lite-image',
123 'google/gemini-3-pro-image',
124 'google/gemini-2.5-flash-image',
125] as const
126​
127export type LovableImageModel = (typeof LOVABLE_IMAGE_MODELS)[number]
128​
129export type LovableImageModelProviderOptionsByName = {
130 [K in LovableImageModel]: LovableImageProviderOptions
132​
133export type LovableImageModelSizeByName = {
134 [K in LovableImageModel]: LovableImageSize
136​
137export type LovableImageModelInputModalitiesByName = {
138 [K in LovableImageModel]: readonly ['image']
140​
141/**
142 * @experimental Video generation is an experimental feature and may change.
143 */
144export const LOVABLE_VIDEO_MODELS = [
145 'google/veo-3.1-lite',
146 'google/veo-3.1-fast',
147 'google/veo-3.1',
148] as const
149​
150/**
151 * @experimental Video generation is an experimental feature and may change.
152 */
153export type LovableVideoModel = (typeof LOVABLE_VIDEO_MODELS)[number]
154​
155export type LovableVideoModelProviderOptionsByName = {
156 [K in LovableVideoModel]: LovableVideoProviderOptions
158​
159export type LovableVideoModelSizeByName = {
160 'google/veo-3.1-lite': LovableHdVideoSize
161 'google/veo-3.1-fast': LovableVideoSize
162 'google/veo-3.1': LovableVideoSize
164​
165export type LovableVideoModelDurationByName = {
166 [K in LovableVideoModel]: LovableVideoDuration
168​
169export type LovableVideoModelInputModalitiesByName = {
170 [K in LovableVideoModel]: readonly ['image']
172​
173export const LOVABLE_EMBEDDING_MODELS = [
174 'google/gemini-embedding-2',
175 'google/gemini-embedding-001',
176 'openai/text-embedding-3-small',
177 'openai/text-embedding-3-large',
178] as const
179​
180export type LovableEmbeddingModel = (typeof LOVABLE_EMBEDDING_MODELS)[number]
181​
182export type LovableEmbeddingModelProviderOptionsByName = {
183 [K in LovableEmbeddingModel]: LovableEmbeddingProviderOptions
185​
186export type LovableEmbeddingModelInputModalitiesByName = {
187 [K in LovableEmbeddingModel]: readonly ['text']
189​
190export const LOVABLE_TTS_MODELS = [
191 'openai/gpt-4o-mini-tts',
192 'google/gemini-2.5-flash-tts',
193 'google/gemini-2.5-pro-tts',
194 'google/gemini-2.5-flash-lite-preview-tts',
195 'google/gemini-3.1-flash-tts-preview',
196] as const
197​
198export type LovableTTSModel = (typeof LOVABLE_TTS_MODELS)[number]
199​
200export const LOVABLE_TRANSCRIPTION_MODELS = [
201 'openai/gpt-4o-mini-transcribe',
202 'openai/gpt-4o-transcribe',
203] as const
204​
205export type LovableTranscriptionModel =
206 (typeof LOVABLE_TRANSCRIPTION_MODELS)[number]
207​
208// Reasoning
209//
210// Each model's data for `chat({ reasoning })`: the levels it has, with the
211// provider value for each, and whether it takes a thinking token budget. The
212// data comes from models.dev. The generator that writes it comes with the model
213// catalog later. Until then, edit these entries by hand.
214​
215const LOVABLE_REASONING = {
216 'google/gemini-3.7-flash': EFFORT_LOW_TO_HIGH,
217 'google/gemini-3.6-flash': EFFORT_MINIMAL_TO_HIGH,
218 'google/gemini-3.5-flash': EFFORT_MINIMAL_TO_HIGH,
219 'google/gemini-3.1-pro-preview': EFFORT_LOW_TO_HIGH,
220 'google/gemini-3.1-flash-lite': EFFORT_MINIMAL_TO_HIGH,
221 'google/gemini-3-flash-preview': EFFORT_MINIMAL_TO_HIGH,
222 'google/gemini-2.5-pro': BUDGET_MINIMAL_TO_HIGH,
223 'google/gemini-2.5-flash': BUDGET_OFF_HIGH,
224 'google/gemini-2.5-flash-lite': BUDGET_OFF_HIGH,
225 'openai/gpt-5.6-sol': EFFORT_NONE_LOW_TO_MAX,
226 'openai/gpt-5.6-terra': EFFORT_NONE_LOW_TO_MAX,
227 'openai/gpt-5.6-luna': EFFORT_NONE_LOW_TO_MAX,
228 'openai/gpt-5.5-pro': EFFORT_MEDIUM_TO_XHIGH,
229 'openai/gpt-5.5': EFFORT_NONE_LOW_TO_XHIGH,
230 'openai/gpt-5.4-pro': EFFORT_MEDIUM_TO_XHIGH,
231 'openai/gpt-5.4': EFFORT_NONE_LOW_TO_XHIGH,
232 'openai/gpt-5.4-mini': EFFORT_NONE_LOW_TO_XHIGH,
233 'openai/gpt-5.4-nano': EFFORT_NONE_LOW_TO_XHIGH,
234 'openai/gpt-5.2': EFFORT_NONE_LOW_TO_XHIGH,
235 'openai/gpt-5': EFFORT_MINIMAL_TO_HIGH,
236 'openai/gpt-5-mini': EFFORT_MINIMAL_TO_HIGH,
237 'openai/gpt-5-nano': EFFORT_MINIMAL_TO_HIGH,
238} satisfies Partial<Record<LovableChatModel, ModelReasoning>>
239​
240/**
241 * Each model's reasoning levels, and whether it takes a token budget, for
242 * `chat({ reasoning })`. A model that is not here does not reason.
243 */
244export type LovableModelReasoningByName = {
245 [K in keyof typeof LOVABLE_REASONING]: ModelReasoningCapability<
246 (typeof LOVABLE_REASONING)[K]
247 >
249​
250/**
251 * Runtime map from model id to its reasoning data, for the text adapter. An
252 * unknown id gives `undefined`: the adapter sends no reasoning field.
253 */
254export const LOVABLE_MODEL_REASONING: Readonly<Record<string, ModelReasoning>> =
255 LOVABLE_REASONING