Vercel AI SDK
Use Cortecs with the Vercel AI SDK
The Vercel AI SDK supports both the Responses API and OpenAI-compatible Chat Completions. Use Responses for new agent workflows.
Responses API
Install the required packages:
npm install ai @ai-sdk/openaiConfigure the OpenAI provider with the Cortecs base URL:
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const cortecs = createOpenAI({
name: "cortecs",
apiKey: process.env.CORTECS_API_KEY,
baseURL: "https://api.cortecs.ai/v1",
});
const { text } = await generateText({
model: cortecs.responses(process.env.CORTECS_MODEL!),
prompt: "Explain model routing in two sentences.",
});
console.log(text);Choose a model that advertises the capabilities your application uses in the Models API.
Chat Completions fallback
If a workflow or middleware expects Chat Completions, use the OpenAI-compatible provider:
Provider options are forwarded in the request body by the OpenAI-compatible provider. See Advanced Usage for the Cortecs routing fields you can pass.
See the Vercel AI SDK documentation for the OpenAI provider and OpenAI-compatible providers.
Last updated