add-ai-model
Add, update, or retire an AI provider model option for the BYOK theme generator (OpenAI, Anthropic, Google) and verify the provider requests native structured output for it. Use when model lists go st
SKILL.md.claude/skills/add-ai-model/SKILL.md
GitHubAdd or update an AI model: $ARGUMENTS
- Verify the model ID against the provider's current documentation. Model IDs change and retire; don't guess. The server passes the string straight to the provider, so a bad ID only fails at request time.
- Model list: edit
AI_MODELSinapp/types/ai.ts(label,value, one-linedescription). The first model for a provider is its default: it's selected when the user switches providers, andresolveAiModelsubstitutes it for a saved ID that's no longer listed, so retiring a model never strands users.DEFAULT_AI_SETTINGS.modelmust stay equal to the first OpenAI model (a unit test checks this). Prefer stable models over previews, which providers retire with little notice. - New provider (rare): add it to
AI_PROVIDERSandAI_PROVIDER_OPTIONS, and toAI_PROVIDER_IDSandcreateProviderModelinserver/utils/aiGenerate.ts(the route's zod enum usesAI_PROVIDER_IDS). Install the@ai-sdk/<provider>package withpnpm add. Map provider-specific errors inserver/utils/aiErrorHandler.ts, and extend the "listed models" test with the provider's request shape. - Structured output:
server/utils/aiGenerate.tscallsgenerateTextwithOutput.object({ schema })(AI SDK 7), and the system prompt goes ininstructions. System messages insidemessagesare rejected. The "listed models" test intests/unit/server/utils/aiGenerate.test.tssends every listed model through its real provider (withfetchstubbed, no key needed) and asserts it requests native JSON-schema output. Reasoning models (GPT-6, Claude Opus 5.5) reject the forced tool call older SDK paths use, so a model that fails this test won't work in production. - Tests: update
tests/unit/composables/useAiSettings.test.tsand any tests that assert on model lists, then runpnpm vitest run tests/unit/composables/useAiSettings.test.ts tests/unit/server. - E2E: AI e2e specs mock
/api/ai/generate, so they only cover the settings UI. A real end-to-end check needs a key in the app UI via/run-app, and must never be committed.