The default model
Step-by-step guide: give apps that say ai: { chat: true } a default model with one provider's key (OpenRouter first), pick it with everyapp ai default, check it.
An app that says ai: { chat: true } in its manifest (OpenMail,
OpenCRM's research agent) takes the workspace's default chat model,
through /api/ai/default/…; it never names a provider. One key, set
once, makes every such app work. This guide sets that one key and, when
the person wants a particular provider or model, the one setting
(<provider>[/<model>]). At the end the person has one model provider's key on the
Gateway, pnpm everyapp ai show saying what the default resolves to,
and every app that needs "a chat model" open.
Settings
| NAME | Required or optional | What it holds |
|---|---|---|
one provider's key (OPENROUTER_API_KEY first in the order) |
required by every app whose manifest says ai.chat |
the provider's key as its file says (openrouter.md, workers-ai.md, openai.md, or providers.md under anthropic, groq, mistral, gemini) |
the setting (pnpm everyapp ai default <provider>[/<model>]) |
optional | which provider (and model) the default is; without it the order decides |
The order the Gateway resolves the default in, the first whose settings
are set: openrouter (one key, many models, the price in every answer),
workers-ai (no provider account: the Gateway's own Cloudflare token;
weaker models), openai, anthropic, groq, mistral, gemini. The
setting wins over the order. Cloudflare AI Gateway is never
the default: it fronts whichever provider resolves
(ai-gateway.md).
Costs and plans
The provider's: OpenRouter is prepaid in USD at the providers' own
prices (openrouter.md); Workers AI bills the Cloudflare
account per token (workers-ai.md); the others each have
a plan of their own, named in their section of
providers.md. The model the Gateway fills in when an app
names none is a cheap capable one per provider (OpenRouter
anthropic/claude-haiku-5.5, Workers AI
@cf/meta/llama-4-scout-17b-16e-instruct, OpenAI gpt-6-luna, Groq
openai/gpt-oss-20b, Mistral mistral-small-latest, Gemini
gemini-3.1-flash-lite); pnpm everyapp ai default <provider>/<model>
picks another. Usage by provider and model is on Manage workspace →
Usage and in pnpm everyapp workspace usage --json (byModel).
Only a person can
- Open an account with the provider and buy credits or add a card.
- Create the key there and paste it into the terminal (the value never goes through the chat or the command line).
- Decide the provider and model when the shipped order isn't what they want (a model they trust, a region, a budget).
Before you start
pnpm everyapp status --json:data.installedanddata.claimedtrue; otherwise gateway.md first.- Whether this guide applies: an app in
data.apps[]whosesetup.unmethas a setting withkind: "ai-default"(label "A chat model (…)"), or whosesetup.settingslists one. Itsnamesis the key the order asks for first and itshintnames the alternatives. No such app: nothing to do here; an app that pins a provider is that provider's file. pnpm everyapp ai show --json:done.data.configuredfalse means no provider is set yet;done.data.provideranddone.data.settingssay which key the default would use;done.data.candidates[]lists every provider withconfigured.
Steps
- Pick the provider with the person. Default to OpenRouter unless they say otherwise: it is one key for every model and the only one whose spend the Gateway counts in dollars. Workers AI when they want no provider account at all. A single vendor when they already have a key there.
- Set that provider's key, by its own file: openrouter.md
(
OPENROUTER_API_KEY), workers-ai.md (WORKERS_AI_API_TOKEN), openai.md (OPENAI_API_KEY), or the provider's section of providers.md (ANTHROPIC_API_KEY,GROQ_API_KEY,MISTRAL_API_KEY,GEMINI_API_KEY). Each ends withpnpm everyapp secret set <NAME>, the value from the person's terminal, orpnpm everyapp configure <app id>, which asks for exactly the one key the app'sai-defaultsetting names. - Store the setting when it isn't the order's. The first configured
provider of the order is the default by itself, with its catalog
model; nothing to store when it is OpenRouter and the person is happy
with its model. Otherwise:
pnpm everyapp ai default <provider>(groq), or with a model,pnpm everyapp ai default openrouter/anthropic/claude-sonnet-5.5(the provider id up to the first slash, the model after it).pnpm everyapp ai default offclears it. Each change queues theai.default_changedevent. Embeddings always use the provider's catalog model. The same setting is Manage workspace → Usage → AI default in the browser. - Optionally put AI Gateway in front: ai-gateway.md
(
pnpm everyapp ai gateway on), for logs, caching and limits on every model call; it changes no app and no key.
Verify
pnpm everyapp ai show --json:done.data.configuredtrue,done.data.providerthe one the person picked (or the order's first),done.data.modelthe model that will be filled in,done.data.viaai-gatewayonce the gateway is on, elsedirect.pnpm everyapp status --json: every app that saidai.chathassetup.readytrue and noai-defaultsetting insetup.unmet.- In the app: a chat answer arrives (OpenMail: open a thread and ask the agent; OpenCRM: run research on a company). Manage workspace → Usage → By provider shows the provider and, under it, the model.
If it fails
ai_default_not_configuredin an app's error (503): no provider's key is set, or the chosen one's isn't. The message names the key; step 2.pnpm everyapp ai showsays the same withconfigured: false.AI_DEFAULT_INVALIDfromai default: the id isn't a provider the Gateway knows, is an API provider (Stripe), has no OpenAI-shaped chat route (Cohere: an app pins it underproviders), or isai-gateway(turn it on withai gateway onand pick a model provider). The message names the candidates.ai_route_not_allowedon the default route: the app called something other than chat completions or embeddings; it lists the provider underprovidersfor that.model_not_allowednever comes from the default route; an app seeing it pinned a provider and limitedai.models.- A provider's own error (401, 429, a model name it doesn't serve): the provider's file, "If it fails".
Rerun, rotate, remove
- Rerunning any step is safe:
ai defaultoverwrites the setting, a key set again replaces the old one on the next request. - Rotate a key as its provider's file says; the default resolves to the same provider.
- Remove the setting with
pnpm everyapp ai default off; remove a key withpnpm everyapp secret unset <NAME>, after which the order moves to the next configured provider, or apps that need the default show "Needs setup" again.
Sources
- https://everyapp.com/docs/agent/ai (in the checkout
landing-page/content/agent/ai.md): the route, the order, the commands and their--json, the event. packages/sdk/src/internal/aiDefault.ts: the resolution rule.
Email sending for the Gateway
Step-by-step guide: let the Gateway and its apps send mail (Cloudflare Email Sending or Resend): onboarding the domain, EMAIL_FROM and EMAIL_FROM_NAME, app senders and inbound addresses, the check.
OpenRouter for the Gateway
Step-by-step guide: an OpenRouter key (OPENROUTER_API_KEY) on the Gateway, the model provider most apps use: the account, credits, the key, the check, rotation.