mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 01:40:13 -04:00
0c5f64fcba
Replaces `gpt-5-mini` and `gpt-5` with `gpt-5.4-nano` and `gpt-5.3-codex` respectively. Clients with stale model IDs in IndexedDB will gracefully reset to the new defaults. While we can technically keep the existing models around, we've [opted](https://supabase.slack.com/archives/C051L8U2EJF/p1774283070517609?thread_ts=1773771991.871669&cid=C051L8U2EJF) to replace them w/ the newer models for simplicity. Basic completion endpoints use `'none'` reasoning level for optimal speed. Rationale for these models is they provide they best balance of intelligence/speed and cost. GPT-5.4-nano is less expensive (0.8x price), faster, and smarter than GPT-5-mini. GPT-5.4-mini would be even smarter but is 3x the price. GPT-5.3-Codex is ~1.4x the price of GPT-5, while GPT-5.4 would be 2x price, but 5.3-Codex is still a big intelligence boost from GPT-5. See [eval comparison](https://www.braintrust.dev/app/supabase.io/p/Assistant/experiments/mattrossman%2Fai-509-v2-upgrade-assistant-models-beyond-gpt-5-family-1774468619?c=master-1774458837&diff=between_experiments), scores are relatively stable and conciseness naturally improves on gpt-5.4-nano. Other change: - Fixed an eval test case to clarify that https://supabase.help is also a correct URL for submitting support ticket, which was unfairly scored as incorrect [here](https://www.braintrust.dev/app/supabase.io/p/Assistant/trace?object_type=experiment&object_id=5244cccd-23b2-4f79-9dd2-287f1b40ebad&r=bac9b903-8bde-4c21-99dd-e0ed141c4f9e&s=f248fbf5-75bf-4aab-be0a-87a4298e6d11) I sanity checked the Assistant, natural language filters, and SQL Editor completions on staging preview. References: - https://openai.com/index/introducing-gpt-5-4-mini-and-nano/ - https://openai.com/index/introducing-gpt-5-3-codex/ - https://developers.openai.com/api/docs/pricing Closes AI-509
168 lines
5.3 KiB
TypeScript
168 lines
5.3 KiB
TypeScript
export type ProviderName = 'bedrock' | 'openai'
|
|
|
|
export type BedrockModel = 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'openai.gpt-oss-120b-1:0'
|
|
|
|
export type OpenAIModelId = 'gpt-5.4-nano' | 'gpt-5.3-codex'
|
|
|
|
// Source: https://developers.openai.com/api/docs/guides/reasoning + per-model pages
|
|
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
|
|
// Per-model reasoning effort compatibility.
|
|
// Sources: https://developers.openai.com/api/docs/models/gpt-5.4-nano
|
|
// https://developers.openai.com/api/docs/models/gpt-5.3-codex
|
|
type ModelReasoningSupport = {
|
|
'gpt-5.4-nano': 'none' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
'gpt-5.3-codex': 'low' | 'medium' | 'high' | 'xhigh'
|
|
}
|
|
|
|
type ReasoningEffortFor<ModelId extends OpenAIModelId> = ModelId extends keyof ModelReasoningSupport
|
|
? ModelReasoningSupport[ModelId]
|
|
: never
|
|
|
|
/** Type-safe factory for configuring OpenAI models with compatible reasoning efforts. */
|
|
export function openaiModelEntry<
|
|
ModelId extends OpenAIModelId,
|
|
RequiresAdvance extends boolean = false,
|
|
>(config: {
|
|
id: ModelId
|
|
/** When true, the model requires the `assistant.advance_model` entitlement (paid plans). Defaults to false. */
|
|
requiresAdvanceModelEntitlement?: RequiresAdvance
|
|
/**
|
|
* When omitted, OpenAI applies its own default reasoning effort for the model,
|
|
* which may not be zero. Use an explicit level to control cost and latency.
|
|
*/
|
|
reasoningEffort?: ReasoningEffortFor<ModelId>
|
|
}): {
|
|
id: ModelId
|
|
requiresAdvanceModelEntitlement: RequiresAdvance
|
|
reasoningEffort?: ReasoningEffortFor<ModelId>
|
|
} {
|
|
return {
|
|
requiresAdvanceModelEntitlement: false as RequiresAdvance,
|
|
...config,
|
|
}
|
|
}
|
|
|
|
export type OpenAIModelEntry = ReturnType<typeof openaiModelEntry>
|
|
|
|
/** Default model entry for simple completion endpoints where latency is more important than reasoning. */
|
|
export const DEFAULT_COMPLETION_MODEL = openaiModelEntry({
|
|
id: 'gpt-5.4-nano',
|
|
reasoningEffort: 'none',
|
|
})
|
|
|
|
// Single source of truth for all Assistant chat model variants and their reasoning levels.
|
|
// Models with requiresAdvanceModelEntitlement false are available to all users; true requires the assistant.advance_model entitlement.
|
|
export const ASSISTANT_MODELS = [
|
|
openaiModelEntry({
|
|
id: 'gpt-5.4-nano',
|
|
requiresAdvanceModelEntitlement: false,
|
|
reasoningEffort: 'low',
|
|
}),
|
|
openaiModelEntry({
|
|
id: 'gpt-5.3-codex',
|
|
requiresAdvanceModelEntitlement: true,
|
|
reasoningEffort: 'low',
|
|
}),
|
|
] as const
|
|
|
|
export type AssistantBaseModelId = Extract<
|
|
(typeof ASSISTANT_MODELS)[number],
|
|
{ requiresAdvanceModelEntitlement: false }
|
|
>['id']
|
|
export type AssistantModelId = (typeof ASSISTANT_MODELS)[number]['id']
|
|
|
|
const ASSISTANT_MODELS_MAP = Object.fromEntries(ASSISTANT_MODELS.map((m) => [m.id, m])) as Record<
|
|
AssistantModelId,
|
|
(typeof ASSISTANT_MODELS)[number]
|
|
>
|
|
|
|
export const DEFAULT_ASSISTANT_BASE_MODEL_ID = 'gpt-5.4-nano' satisfies AssistantBaseModelId
|
|
|
|
export const DEFAULT_ASSISTANT_ADVANCE_MODEL_ID = 'gpt-5.3-codex' satisfies AssistantModelId
|
|
|
|
export function defaultAssistantModelId(hasAccessToAdvanceModel: boolean): AssistantModelId {
|
|
return hasAccessToAdvanceModel
|
|
? DEFAULT_ASSISTANT_ADVANCE_MODEL_ID
|
|
: DEFAULT_ASSISTANT_BASE_MODEL_ID
|
|
}
|
|
|
|
export function isKnownAssistantModelId(id: string): id is AssistantModelId {
|
|
return Object.hasOwn(ASSISTANT_MODELS_MAP, id)
|
|
}
|
|
|
|
export function isAssistantBaseModelId(id: string): id is AssistantBaseModelId {
|
|
return (
|
|
id in ASSISTANT_MODELS_MAP &&
|
|
!ASSISTANT_MODELS_MAP[id as AssistantModelId].requiresAdvanceModelEntitlement
|
|
)
|
|
}
|
|
|
|
export function isAdvanceOnlyModelId(id: string): boolean {
|
|
return (
|
|
id in ASSISTANT_MODELS_MAP &&
|
|
ASSISTANT_MODELS_MAP[id as AssistantModelId].requiresAdvanceModelEntitlement
|
|
)
|
|
}
|
|
|
|
export function getAssistantModelEntry(id: AssistantModelId): (typeof ASSISTANT_MODELS)[number] {
|
|
return ASSISTANT_MODELS_MAP[id]
|
|
}
|
|
|
|
export type Model = BedrockModel | OpenAIModelId
|
|
|
|
export type ProviderModelConfig = {
|
|
/** Optional providerOptions to attach to the system message for this model */
|
|
promptProviderOptions?: Record<string, any>
|
|
/** The default model for this provider (used when limited or no preferred specified) */
|
|
default: boolean
|
|
}
|
|
|
|
export type ProviderRegistry = {
|
|
bedrock: {
|
|
models: Record<BedrockModel, ProviderModelConfig>
|
|
providerOptions?: Record<string, any>
|
|
}
|
|
openai: {
|
|
models: Record<OpenAIModelId, ProviderModelConfig>
|
|
providerOptions?: Record<string, any>
|
|
}
|
|
}
|
|
|
|
export const PROVIDERS: ProviderRegistry = {
|
|
bedrock: {
|
|
models: {
|
|
'anthropic.claude-3-7-sonnet-20250219-v1:0': {
|
|
promptProviderOptions: {
|
|
bedrock: {
|
|
// Always cache the system prompt (must not contain dynamic content)
|
|
cachePoint: { type: 'default' },
|
|
},
|
|
},
|
|
default: false,
|
|
},
|
|
'openai.gpt-oss-120b-1:0': {
|
|
default: true,
|
|
},
|
|
},
|
|
},
|
|
openai: {
|
|
models: {
|
|
'gpt-5.3-codex': { default: false },
|
|
'gpt-5.4-nano': { default: true },
|
|
},
|
|
providerOptions: {
|
|
openai: {
|
|
store: false,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
export function getDefaultModelForProvider(provider: ProviderName): Model | undefined {
|
|
const models = PROVIDERS[provider]?.models as Record<Model, ProviderModelConfig>
|
|
if (!models) return undefined
|
|
|
|
return Object.keys(models).find((id) => models[id as Model]?.default) as Model | undefined
|
|
}
|