Migrate to Kavren
Move an existing Chat Completions call to Kavren. Choose your client to see the three settings that change.
- API address
export KAVREN_BASE_URL=https://kavren.dev/v1- Server-side key
KAVREN_API_KEYSet your customer key in your local environment- Model ID
deepseek-v4.1-flash-fast↗Replace with a route available to your key
Python · openai
Migrate with Python
Read both connection values from the environment when constructing the OpenAI client.
from openai import OpenAI
client = OpenAI()
reply = client.chat.completions.create(
model="current-model-id",
messages=[{"role": "user", "content": "After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?"}],
max_tokens=64,
)
print(reply.choices[0].message.content)import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["KAVREN_BASE_URL"],
api_key=os.environ["KAVREN_API_KEY"],
)
reply = client.chat.completions.create(
model="deepseek-v4.1-flash-fast",
messages=[{"role": "user", "content": "After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?"}],
max_tokens=64,
)
print(reply.choices[0].message.content)Node.js · openai
Migrate with Node.js
Set baseURL and apiKey on your server-side client and use the model ID from the catalog.
import OpenAI from "openai";
const client = new OpenAI();
const reply = await client.chat.completions.create({
model: "current-model-id",
messages: [{ role: "user", content: "After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?" }],
max_tokens: 64,
});
console.log(reply.choices[0].message.content);import OpenAI from "openai";
const client = new OpenAI({
baseURL: process.env.KAVREN_BASE_URL,
apiKey: process.env.KAVREN_API_KEY,
});
const reply = await client.chat.completions.create({
model: "deepseek-v4.1-flash-fast",
messages: [{ role: "user", content: "After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?" }],
max_tokens: 64,
});
console.log(reply.choices[0].message.content);HTTP · Bash
Migrate with cURL
Keep the Chat Completions path, point it to Kavren, and send your customer key in the Authorization header.
curl --fail-with-body "$CURRENT_API_BASE_URL/chat/completions" \
-H "Authorization: Bearer $CURRENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"current-model-id","messages":[{"role":"user","content":"After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?"}],"max_tokens":64}'curl --fail-with-body "$KAVREN_BASE_URL/chat/completions" \
-H "Authorization: Bearer $KAVREN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-v4.1-flash-fast","messages":[{"role":"user","content":"After deployment, the HTTP 503 rate rose from 0.1% to 3%. Which two metrics would you compare first?"}],"max_tokens":64}'Check the connection
Use a catalog request to check your URL and key. Running a generation uses account credit.