Files
Charis ffe1ebc940 fix(studio): do not ignore requested model if available in base (#51388)
## Problem

The model selection logic in `generate-v4.ts` was incorrectly ignoring
the requested model even when it was available in the base model set.
The condition checked for access to advanced models or throttling in a
way that would force fallback to the default base model even when the
requested model was already a base model.

## Solution

Reordered the logical condition to first check if the effective model is
a base model ID, and only apply the access/throttle checks when the
requested model is not already a base model. This ensures the requested
model is respected when it's available.

Also threaded the `effectiveModel` parameter through to the assistant
response generator for better telemetry and debugging context.

## Review instructions

1. Check the logic change in
`apps/studio/pages/api/ai/sql/generate-v4.ts` line 164
2. Verify the condition now correctly checks
`isAssistantBaseModelId(effectiveModel)` first
3. Confirm `effectiveModel` is now passed to `generateAssistantResponse`
for proper telemetry

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-07 09:43:01 -04:00
..