AI GatewayIntegrations

Vercel AI SDK Integration

Integrate Cova AI Gateway with Vercel AI SDK to access LLM providers with full observability.

Introduction

Vercel AI SDK is a TypeScript toolkit for building AI-powered applications with React, Next.js, Vue, and more. The Cova AI Gateway is fully compatible with the Vercel AI SDK's OpenAI provider — just point it at the gateway base URL.

Integration Steps

Sign up at corevalue.dev and generate an API key.

You'll also need to configure your provider API keys (OpenAI, Anthropic, etc.) at Cova Providers for BYOK (Bring Your Own Keys).

COVA_API_KEY=sk-cova-XXXXXXXXXXXXXXXX
pnpm add ai @ai-sdk/openai
npm install ai @ai-sdk/openai
yarn add ai @ai-sdk/openai
bun add ai @ai-sdk/openai
import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

// Point the OpenAI provider at the Cova AI Gateway
const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

// Use any model from the model registry
const result = await generateText({
  model: cova('gpt-4o-mini'),
  prompt: 'Write a haiku about artificial intelligence'
});

console.log(result.text);

You can switch between many models without changing your code. Just update the model name!

While you're here, why not give us a star on GitHub? It helps us a lot!

Complete Working Examples

Basic Text Generation

import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

const { text } = await generateText({
  model: cova('google/gemini-2.5-flash-lite'),
  prompt: 'What is Cova?'
});

console.log(text);

Streaming Text

import { createOpenAI } from '@ai-sdk/openai';
import { streamText } from 'ai';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

const result = await streamText({
  model: cova('deepseek/deepseek-v3.1-terminus'),
  prompt: 'Write a short story about a robot learning to paint',
  maxTokens: 300
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

console.log('\n\nStream completed!');

UI Message Stream Response

Convert streaming results to a UI-compatible response format:

import { createOpenAI } from '@ai-sdk/openai';
import { streamText } from 'ai';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

const result = streamText({
  model: cova('gpt-4o-mini'),
  prompt: 'Say "Hello streaming world!"',
});

const response = result.toUIMessageStreamResponse();

console.log(
  "Response headers:",
  Object.fromEntries(response.headers.entries())
);

Provider Selection

By default, Cova's AI gateway automatically routes to the cheapest provider. You can also manually select a specific provider using the provider/model format:

import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

// Automatic routing (cheapest provider)
const autoResult = await generateText({
  model: cova('gpt-4o'),
  prompt: 'Hello!'
});

// Manual provider selection
const manualResult = await generateText({
  model: cova('anthropic/claude-sonnet-4'),
  prompt: 'Hello!'
});

With Custom Properties and Session Tracking

import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
  headers: {
    'Cova-User-Id': 'user-123',
    'Cova-Property-Environment': 'production',
    'Cova-Property-AppVersion': '2.1.0',
  }
});

const result = await generateText({
  model: cova('anthropic/claude-sonnet-4'),
  prompt: 'Explain quantum computing'
});

Tool Calling

import { createOpenAI } from '@ai-sdk/openai';
import { generateText, tool } from 'ai';
import { z } from 'zod';

const cova = createOpenAI({
  apiKey: process.env.COVA_API_KEY,
  baseURL: 'https://gateway.corevalue.dev/v1',
});

const result = await generateText({
  model: cova('gpt-4o'),
  prompt: 'What is the weather like in San Francisco?',
  tools: {
    getWeather: tool({
      description: 'Get weather for a location',
      parameters: z.object({
        location: z.string().describe('The city name')
      }),
      execute: async (args) => {
        return `It's sunny in ${args.location}`;
      }
    })
  }
});

console.log(result.text);

Request a CoreValue Integration

Looking for a framework or tool not listed here? Request it here!

Additional Resources

On this page