Guides
LLM
Bring your own provider keys and call ctx.llm.complete or ctx.llm.stream from handlers.
Every defineApi, defineJob, and defineSocket handler receives an injected llm client. Keys are per-project, encrypted at rest, and chosen on the dashboard AI page. They are not project Secrets and are never copied into ctx.env. Starbase decrypts the key at call time and talks to the provider from the control plane — tenant bundles never see the secret.
If you omit provider, Starbase uses the first configured key in this order: grok, gemini, openai, anthropic. If none are configured, the call throws llm_not_configured. Per-project rate limits are 60 complete/stream starts per minute and 10 in flight; over that throws llm_rate_limited (HTTP 429).
Default models (grok-4, gemini-2.5-flash, gpt-4.1, claude-sonnet-4-5) are examples used when model is omitted — not an allowlist. Pass any model string the provider accepts. llm.stream is for socket handlers that can yield tokens as they arrive. HTTP handlers that consume the iterator still wait until it finishes (handler timeout still applies; the LLM HTTP client times out around 25s).