Back to blog
Guide·May 23, 2026·6 min read

Migrating from OpenAI to Kunavo in 10 minutes — Python, Node, LangChain, Vercel AI SDK

Four flavors of OpenAI integration, the one-line change each needs to start running through Kunavo, and a smoke-test that costs less than a cent.

If your app already talks to OpenAI's API, switching to Kunavo takes about ten minutes — most of which is signing up. This guide walks through the four flavors of integration most teams have and the one-line change each needs.

Step 0 — Get a key (2 minutes)

  1. Sign up at kunavo.com/app/signup. You get $2 of credit on sign-up; no card required.
  2. Visit /app/keys and create a key. It starts with sk-kunavo-.
  3. Set the env var: export KUNAVO_API_KEY=sk-kunavo-....

Step 1 — Switch your SDK (1 minute)

Python (openai package)

migrate.py
# Before — pointing at OpenAI directly
from openai import OpenAI
client = OpenAI(
    api_key=os.environ["OPENAI_API_KEY"],
)

# After — pointing at Kunavo. Everything else stays the same.
from openai import OpenAI
client = OpenAI(
    api_key=os.environ["KUNAVO_API_KEY"],
    base_url="https://api.kunavo.com/v1",
)

Node / TypeScript

migrate.mjs
// Before
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// After
import OpenAI from "openai";
const client = new OpenAI({
  apiKey: process.env.KUNAVO_API_KEY,
  baseURL: "https://api.kunavo.com/v1",
});

LangChain

LangChain uses the same OpenAI client internally, so the change is identical. The model id is now a Kunavo slug — see /models for the live list (try claude-sonnet-4-6, gemini-3-flash, claude-opus-4-7).

langchain_setup.py
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="claude-sonnet-4-6",          # switched the model
    api_key=os.environ["KUNAVO_API_KEY"],
    base_url="https://api.kunavo.com/v1",
)

Vercel AI SDK

@ai-sdk/openai reads its base URL and API key from env vars by default. Set those and you're done — every framework helper (streamText, generateObject, retries, tool routing) works unchanged.

vercel_ai.mjs
import { openai } from "@ai-sdk/openai";

// @ai-sdk/openai reads OPENAI_BASE_URL automatically
process.env.OPENAI_BASE_URL = "https://api.kunavo.com/v1";
process.env.OPENAI_API_KEY = process.env.KUNAVO_API_KEY;

const model = openai("claude-sonnet-4-6");
// then use streamText / generateText / streamObject as before

Anthropic SDK (if you're on Claude already)

Kunavo exposes Anthropic's native Messages API at /v1/messages as well as the OpenAI shape — so you don't have to switch SDKs.

anthropic_sdk.py
from anthropic import Anthropic

# Before — Anthropic SDK against api.anthropic.com
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

# After — same SDK, against Kunavo. Caching, thinking, tools all pass through.
client = Anthropic(
    api_key=os.environ["KUNAVO_API_KEY"],
    base_url="https://api.kunavo.com",   # SDK appends /v1/messages
)

Step 2 — Smoke-test the wallet (1 minute)

Before touching production code, run a cheap test against claude-haiku-4-5. If this returns successfully, your key works, billing works, the routing layer is healthy.

smoke_test.py
# Cheap, deterministic-ish smoke test for migration validation.
resp = client.chat.completions.create(
    model="claude-haiku-4-5",            # the cheapest Claude
    messages=[{"role": "user", "content": "ping"}],
    max_tokens=8,
    temperature=0,
)
assert resp.choices[0].message.content, "empty response"
print("ok — Kunavo wallet works, total cost ~$0.0001")

Step 3 — Move traffic (5 minutes)

The safe pattern: two environment variables in your app — AI_BASE_URL and AI_API_KEY — selected per-environment. Production stays on OpenAI; staging swaps to Kunavo. After 24 hours, flip prod over.

If you're curious about cost impact before you cut over, Kunavo's dashboard shows per-call cost vs the upstream official rate — easy to compute the projected monthly savings on your real prompts.

What stays the same

  • Your SDK and codebase.
  • Streaming, function calling, tool use, vision, structured outputs.
  • OpenAI's exact request and response schemas.
  • Error shape (error.message / error.type / error.code).

What changes for the better

  • Pricing. Every model is priced at roughly 30% under the official list — see /pricing.
  • Modality. The same SDK reaches Claude (claude-opus-4-7), Gemini (gemini-3-pro), GPT-Image-2, Veo 3, Sora, Flux, Seedream, Suno — see /models.
  • Billing. Stripe wallet in your local currency. Apple Pay, Google Pay, Alipay, WeChat Pay, ACH, SEPA all supported.
  • Failover. Multi-vendor hot failover with sub-50ms reroute when an upstream wobbles.

The unhappy-path notes

  • OpenAI-specific endpoints we don't cover today: /v1/responses (use /v1/chat/completions), /v1/assistants (state on your side; we're a stateless gateway), /v1/realtime (planned).
  • Some Claude-specific features — cache_control, extended thinking — work best via the native /v1/messages endpoint, not the OpenAI shape.

Stuck? contact@kunavo.com — a human replies within a working day. If you're running a serious migration we'll get on a call.