Migrate Your Existing App

Already calling an LLM provider directly? Switch to CloudVera in under a minute. Your existing code stays the same — change the base URL, add two headers, done.

Code Examples

OpenAI — Before

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

OpenAI — After (2-line change)

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: 'cvk_your_cloudvera_key',          // ← CloudVera virtual key
  baseURL: 'https://api.cloudvera.io/v1',              // ← CloudVera gateway
  defaultHeaders: {
    'X-Provider-Key': process.env.OPENAI_API_KEY,  // ← Your real key
  },
});

// Everything else stays exactly the same
const completion = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

Anthropic — Before

import Anthropic from '@anthropic-ai/sdk';

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

Anthropic — After (2-line change)

import Anthropic from '@anthropic-ai/sdk';

const anthropic = new Anthropic({
  apiKey: 'cvk_your_cloudvera_key',
  baseURL: 'https://api.cloudvera.io/v1',
  defaultHeaders: {
    'X-Provider-Key': process.env.ANTHROPIC_API_KEY,
  },
});

Google Gemini — Before (native SDK)

// Native Gemini SDK with Google-specific format
const response = await fetch(
  'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-goog-api-key': GEMINI_KEY },
    body: JSON.stringify({
      contents: [{ role: 'user', parts: [{ text: 'Hello!' }] }],
    }),
  }
);

Google Gemini — After (use OpenAI SDK)

// Switch to OpenAI SDK — CloudVera translates to Gemini format automatically
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'cvk_your_cloudvera_key',
  baseURL: 'https://api.cloudvera.io/v1',
  defaultHeaders: { 'X-Provider-Key': process.env.GEMINI_API_KEY },
});

const completion = await client.chat.completions.create({
  model: 'gemini-2.5-flash',  // Just use the model name
  messages: [{ role: 'user', content: 'Hello!' }],
});

Direct fetch — Before

const response = await fetch('https://api.openai.com/v1/chat/completions', {
  headers: {
    'Authorization': 'Bearer sk-your-openai-key',
    'Content-Type': 'application/json',
  },
  method: 'POST',
  body: JSON.stringify({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello!' }] }),
});

Direct fetch — After

const response = await fetch('https://api.cloudvera.io/v1/chat/completions', {
  headers: {
    'Authorization': 'Bearer cvk_your_cloudvera_key',  // ← CloudVera key
    'X-Provider-Key': 'sk-your-openai-key',             // ← Your real key
    'Content-Type': 'application/json',
  },
  method: 'POST',
  body: JSON.stringify({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello!' }] }),
});