AI Setup
NuxtBase includes an AI chat feature backed by the Vercel AI SDK.
At the template level, AI setup is intentionally small:
- choose a provider
- choose a model
- provide the matching API key
The provider abstraction currently supports:
openaiopenrouter
The Default AI Configuration
Section titled “The Default AI Configuration”The example env file starts with:
NUXT_AI_PROVIDER=openaiNUXT_AI_MODEL=gpt-4o-miniNUXT_OPENAI_API_KEY=sk-...That means the default assumption is: use OpenAI unless you explicitly switch to OpenRouter.
Before You Skip AI Setup
Section titled “Before You Skip AI Setup”If you are not enabling AI yet, clear the placeholder API keys after copying .env.example:
# NUXT_OPENAI_API_KEY=# NUXT_OPENROUTER_API_KEY=You can leave the provider and model defaults in place for now, but do not leave
fake non-empty keys such as sk-... in the file. Those values look disabled to a
human, but they are still non-empty strings in runtime config.
OpenAI Setup
Section titled “OpenAI Setup”Use this when you want the simplest path:
NUXT_AI_PROVIDER=openaiNUXT_AI_MODEL=gpt-4o-miniNUXT_OPENAI_API_KEY=sk-...If NUXT_AI_PROVIDER is openai, the template builds the model through createOpenAI() and uses NUXT_OPENAI_API_KEY.
How to Get an OpenAI API Key
Section titled “How to Get an OpenAI API Key”Official OpenAI references:
Practical setup steps:
- Sign in to the OpenAI API platform.
- Open your API project and go to the API keys page.
- Create a new secret key and copy it immediately.
- Paste that value into
NUXT_OPENAI_API_KEYin.env. - Restart your local dev server.
For a first key on a new OpenAI API account, OpenAI may require phone verification before the key can be created.
OpenRouter Setup
Section titled “OpenRouter Setup”Use this if you want model routing or access to models through OpenRouter:
NUXT_AI_PROVIDER=openrouterNUXT_AI_MODEL=openai/gpt-4o-miniNUXT_OPENROUTER_API_KEY=sk-or-...If NUXT_AI_PROVIDER is openrouter, the template builds the model through createOpenRouter() and uses NUXT_OPENROUTER_API_KEY.
How to Get an OpenRouter API Key
Section titled “How to Get an OpenRouter API Key”Official OpenRouter references:
Practical setup steps:
- Sign in to OpenRouter.
- If you plan to use paid models, add credits to the account you will test with.
- Open the API key settings page and create a new API key.
- Give the key a clear label and optionally set a credit limit.
- Paste that value into
NUXT_OPENROUTER_API_KEYin.env. - Restart your local dev server.
If you only want to test the wiring first, start with one inexpensive model and verify the app boots cleanly before you experiment with more expensive routing options.
What Happens If You Skip AI Setup
Section titled “What Happens If You Skip AI Setup”If you are postponing AI, remove the placeholder API keys and stop here.
AI setup is optional for initial app boot, but if you do enable it, use a real provider key and a model name that matches that provider.
Recommended Setup Sequence
Section titled “Recommended Setup Sequence”- get the app working without AI first
- choose
openaioropenrouter - set the provider, model, and matching key
- start the app and confirm configuration errors are gone
- move on to the AI feature docs when you want to test the full in-app behavior
Good First Test
Section titled “Good First Test”For the setup layer, the first useful check is small:
- set the provider, model, and matching API key
- restart the app
- confirm startup does not fail because of missing or malformed AI config
If you want to verify the actual chat flow, credits behavior, wallet state, or in-app usage rules, cover that in the later features/ai-chat documentation rather than here.
For provider setup errors, check these in order:
- wrong provider key
- wrong model name
- provider and model do not match each other