AI Overview
Multi-provider AI orchestration powered by the Vercel AI SDK.
The ai workspace wraps the Vercel AI SDK. Use chatCompletion(messages, options?) for the common text response contract:
import { chatCompletion } from "ai";
const response = await chatCompletion([
{ role: "user", content: "Write a tagline for a developer SaaS." },
], { temperature: 0.5, maxTokens: 100 });
console.log(response.text);AiAdapter returns { text: string }. Its options accept an optional model, temperature and maximum output tokens. MOCK_SERVICES=true, AI_PROVIDER=mock, or automatic selection with no keys uses an offline mock response.
Direct model access
For real-provider streaming, structured output or tool calling, use getLanguageModel(provider?, modelName?, credentials?) with the exported SDK helpers:
import { getLanguageModel, generateText } from "ai";
const model = await getLanguageModel("openai", "your-enabled-model-id");
const result = await generateText({ model, prompt: "Summarize this release." });Replace the model placeholder with a model available to your provider account. generateText, streamText and generateObject are re-exported SDK functions. getLanguageModel() throws when the selected provider is mock; use chatCompletion() for offline responses. The mock adapter is not a streaming or tool-execution emulator.
The widget's server procedure owns its context, permissions and saved integration resolution. Calling the low-level package directly does not automatically apply those application-specific checks.
Copilot budget and timeout
The live copilot reserves a conservative token allowance before it calls a provider. AI_COPILOT_GLOBAL_DAILY_TOKENS defaults to 20000000 per UTC day, and AI_COPILOT_MAX_CONCURRENT defaults to 8 in-flight requests. Invalid values deny new work rather than silently disabling the limit. These are application ceilings, not provider billing figures.
The SDK deadline is 30 seconds and an unacknowledged reservation lease lasts 120 seconds. If usage is known after a completed request, unused reserved allowance is returned. Unknown usage, provider failure, or a process crash keeps the conservative charge. This prevents a failed accounting step from turning into unbounded provider use.
See AI Providers for selection and extension instructions.