From the Vercel AI Gateway
Cloakray speaks the same protocol as the AI SDK's gateway provider, so an app built on the Vercel AI Gateway moves without changing its model calls.
Apps that use bare model strings
If your code passes strings like model: "anthropic/claude-sonnet-4.6", the AI SDK sends them through its default gateway provider. Repoint that provider once, before the first model call — in instrumentation.ts or your server entry:
import { createGateway } from "@ai-sdk/gateway";
globalThis.AI_SDK_DEFAULT_PROVIDER = createGateway({
baseURL: "https://api.cloakray.com/v3/ai",
apiKey: process.env.CLOAKRAY_API_KEY,
});
Use /v1/ai for AI SDK 5, /v3/ai for AI SDK 6 and /v4/ai for AI SDK 7.
Then change the model strings to Cloakray IDs, which have no provider prefix: anthropic/claude-sonnet-4.6 becomes claude-sonnet-4-6, openai/gpt-5.5 becomes gpt-5.5. The models page has every ID.
Apps that use the OpenAI-compatible endpoint
const client = new OpenAI({
- baseURL: "https://ai-gateway.vercel.sh/v1",
- apiKey: process.env.AI_GATEWAY_API_KEY,
+ baseURL: "https://api.cloakray.com/v1",
+ apiKey: process.env.CLOAKRAY_API_KEY,
});
What changes
providerOptions.gateway(provider order and allowlists) is not supported; drop it.gateway.getAvailableModels()lists Cloakray's text models and their prices, andgateway.getCredits()returns your balance.- Each reply reports its charged cost in
usage.cost(usage and cost), and every request appears in your logs and analytics.
See Vercel AI SDK for the other ways to connect, including the OpenAI-compatible and Anthropic providers.