Caveman
Framework integrationsVercel AI SDK

Vercel AI SDK

Use the OpenAI-compatible provider for OpenAI-protocol models; the Anthropic provider takes a base URL too. Either way the gateway keeps each model on its native protocol.

Vercel AI SDK
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const caveman = createOpenAICompatible({
name: "caveman",
baseURL: "http://127.0.0.1:8787/w/my-service/openai/v1",
apiKey: process.env.OPENAI_API_KEY,
});

const { text } = await generateText({
model: caveman("gpt-4.1"),
prompt: "Why is the sky blue?",
});

// Anthropic models keep their native protocol (no translation):
// import { createAnthropic } from "@ai-sdk/anthropic";
// const anthropic = createAnthropic({ baseURL: "http://127.0.0.1:8787/w/my-service/v1" });

Use @ai-sdk/openai-compatible for OpenAI-protocol models; the Anthropic provider takes a baseURL too.

Local vs. connected

The base URL above is the local proxy default (http://127.0.0.1:8787). Connected or managed use swaps in the cloud gateway URL and adds x-cave-api-key (gateway auth) plus x-cave-upstream-key (your per-request provider key) as request headers on the same client.