Skip to Content
StackBlaze Templates — operator documentation

AI providers

The AI chat layer is built on the Vercel AI SDK, so the provider is a config choice, not a rewrite. You pick one at scaffold time, and you can switch later.

Selecting a provider

Two env vars drive it:

AI_PROVIDER="openai" # which provider AI_MODEL="gpt-4.1-mini" # which model (provider default if omitted) OPENAI_API_KEY="sk-..." # the key for that provider

Only the API key for your selected provider needs a value.

Supported providers

openai, anthropic, google, xai, groq, mistral, cohere, togetherai, fireworks, deepinfra, deepseek, cerebras, perplexity, azure, bedrock, vertex, baseten, openrouter, ollama.

Each provider expects its own key (or credentials):

ProviderKey / credential
openaiOPENAI_API_KEY
anthropicANTHROPIC_API_KEY
googleGOOGLE_GENERATIVE_AI_API_KEY
xaiXAI_API_KEY
groqGROQ_API_KEY
mistralMISTRAL_API_KEY
cohereCOHERE_API_KEY
bedrockAWS_ACCESS_KEY_ID (+ AWS creds)
vertexGOOGLE_VERTEX_PROJECT (+ GCP creds)
openrouterOPENROUTER_API_KEY — also unlocks any upstream model via AI_MODEL
ollamaOLLAMA_BASE_URL (local, no key)

(The remaining providers follow the same <PROVIDER>_API_KEY pattern — see .env.example in your project for the exact names.)

Switching providers after scaffold

The scaffolder only installs the SDK for the provider you chose. To switch to a different one:

  1. Install the matching package, e.g. npm i @ai-sdk/anthropic.
  2. Change AI_PROVIDER and AI_MODEL in .env.local.
  3. Set that provider’s API key.
  4. Restart the dev server.

If you stay within the provider you picked, just change AI_MODEL — no install needed.

Local models with Ollama

ollama needs no API key. Point it at your local server:

AI_PROVIDER="ollama" AI_MODEL="llama3.1" OLLAMA_BASE_URL="http://localhost:11434/v1"

Deploying on Vercel

If you deploy to Vercel, you can route models through the Vercel AI Gateway for observability and failover instead of wiring a provider key directly — see Deployment → Vercel.