On this page
01
Point the Vercel AI SDK at Cloptima
The Vercel AI SDK's OpenAI provider takes a base URL, so you only change configuration — not your generateText/streamText calls. Use a Cloptima virtual key and pass attribution on the headers option.
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const cloptima = createOpenAI({
baseURL: "https://api.cloptima.ai/v1/ai",
apiKey: process.env.CLOPTIMA_VIRTUAL_KEY, // clop_vk_dPXO67p…
headers: { "x-cloptima-team": "web", "x-cloptima-app": "chat", "x-cloptima-environment": "production" },
});
const { text } = await generateText({ model: cloptima("gpt-5.4-mini"), prompt });02
Attribute per route and workspace
Set x-cloptima-feature, x-cloptima-session-id, and x-cloptima-run-id per request to tie spend to a route, customer workspace, or agent run — not just an app total.
03
Add gateway controls when you need them
Because traffic already flows through Cloptima, budgets, model allowlists, provider access, and no-retention prompt policy apply without further app changes.
04
Operationalize
Use separate virtual keys and policies for preview, staging, and production deployments, and review unattributed usage as part of release readiness.