Skip to main content
llm.kiwi is designed as a drop-in replacement for the OpenAI API. Migrating requires minimal code changes—often just updating the base URL.

Quick Migration

Python

Before (OpenAI)
from openai import OpenAI

client = OpenAI(
    api_key="sk-..."
)
After (llm.kiwi)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.llm.kiwi/v1",  # Add this line
    api_key="your-llm-kiwi-key"           # Use llm.kiwi key
)

Node.js

Before (OpenAI)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: "sk-..."
});
After (llm.kiwi)
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.llm.kiwi/v1',  // Add this line
  apiKey: process.env.LLM_KIWI_API_KEY  // Use llm.kiwi key
});

Model Mapping

Map OpenAI models to llm.kiwi equivalents:
OpenAI Modelllm.kiwi EquivalentNotes
gpt-4gpt-oss-20bHigh capability open variant
gpt-4-turbogpt-oss-20bBalanced performance
gpt-3.5-turbodefaultFast routing
gpt-4o-minidefaultModel-lite routing
Use llm.kiwi’s default model to let our router automatically select the best model for each request.

API Compatibility

llm.kiwi supports most OpenAI endpoints:
EndpointStatus
/v1/chat/completions✅ Full support
/v1/images/generations✅ Full support
/v1/audio/transcriptions✅ Full support
/v1/models✅ Full support
/v1/embeddings⚠️ Coming soon
/v1/assistants⚠️ Coming soon

Feature Compatibility

FeatureSupported
Streaming
JSON Mode✅ (Pro)
Function Calling✅ (Pro)
Vision (image input)✅ (Pro)
Temperature/Top P
Max Tokens

Environment Variables

Update your environment configuration:
Before
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.openai.com/v1
After
LLM_KIWI_API_KEY=your-key-here
LLM_KIWI_BASE_URL=https://api.llm.kiwi/v1

Framework-Specific Guides

LangChain

Python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.llm.kiwi/v1",
    api_key="your-llm-kiwi-key",
    model="gpt-oss-20b"
)

LlamaIndex

Python
from llama_index.llms.openai import OpenAI

llm = OpenAI(
    api_base="https://api.llm.kiwi/v1",
    api_key="your-llm-kiwi-key",
    model="gpt-oss-20b"
)

Vercel AI SDK

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

const llmkiwi = createOpenAI({
  baseURL: 'https://api.llm.kiwi/v1',
  apiKey: process.env.LLM_KIWI_API_KEY
});

Testing Your Migration

Verify your migration works correctly:
Python
# Test basic functionality
response = client.chat.completions.create(
    model="default",
    messages=[{"role": "user", "content": "Hello, is this working?"}]
)
print("✅ Basic request:", response.choices[0].message.content[:50])

# Test streaming
stream = client.chat.completions.create(
    model="default",
    messages=[{"role": "user", "content": "Count to 3"}],
    stream=True
)
print("✅ Streaming:", end=" ")
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
print()

print("🎉 Migration successful!")

Common Issues

OpenAI model names don’t work directly. Use llm.kiwi models:
  • gpt-4gpt-oss-20b (or other Pro models)
  • gpt-3.5-turbodefault
Some newer OpenAI features may not be available yet. Check our API Reference for current support.
llm.kiwi has different rate limits. Review Rate Limits for your tier.

Need Help?

Contact support if you encounter migration issues.