๐Ÿ”„ Migrating from OpenAI to DeepSeek: Complete Guide

Last updated: July 29, 2026 ยท 8 min read ยท Python, Node.js, cURL examples

Save 80-98% on your AI API bill in 5 minutes
Drop-in replacement for OpenAI. Same SDK, same format, lower price.
Get API Key โ†’

The 2-Line Migration

If you're using the official OpenAI SDK, migration is literally two changes:

- client = OpenAI(api_key="sk-...")
+ client = OpenAI(api_key="your-aitoken-key", base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1")
- model="gpt-4o"
+ model="deepseek-v4"

Everything else โ€” your prompts, parsing logic, streaming code, function calling โ€” works the same.

Step-by-Step Migration

1 Get Your API Key

Sign up at our dashboard. Free tier includes 100 requests/day.

2 Choose Your Model

deepseek-v4โ†’ Replace GPT-4o / Claude Sonnet
deepseek-v3โ†’ Replace GPT-4o-mini / cheaper alternative
deepseek-r1โ†’ Replace o1/o3 for reasoning tasks
deepseek-v4-flashโ†’ Replace GPT-4o-mini for simple tasks
qwen3.6-flashโ†’ Ultra-cheap, high throughput

3 Update Your Code

Python (openai SDK)

from openai import OpenAI

# Before
client = OpenAI(api_key="sk-proj-...")

# After
client = OpenAI(
    api_key="ait-your-key-here",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

# Everything else stays the same
response = client.chat.completions.create(
    model="deepseek-v4",  # changed from gpt-4o
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ],
    temperature=0.7,
    max_tokens=1024,
)
print(response.choices[0].message.content)

Node.js (openai SDK)

import OpenAI from 'openai';

// Before
// const client = new OpenAI({ apiKey: 'sk-...' });

// After
const client = new OpenAI({
  apiKey: 'ait-your-key-here',
  baseURL: 'https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1'
});

const response = await client.chat.completions.create({
  model: 'deepseek-v4',
  messages: [
    { role: 'user', content: 'Hello!' }
  ]
});

console.log(response.choices[0].message.content);

cURL

curl https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ait-your-key-here" \
  -d '{
    "model": "deepseek-v4",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Framework-Specific Migration

LangChain

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-v4",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    api_key="ait-your-key-here",
)
# All chains, agents, and tools work unchanged
# See our full LangChain guide โ†’

CrewAI

from crewai import LLM, Agent

llm = LLM(
    model="deepseek-v4",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    api_key="ait-your-key-here",
)

agent = Agent(role="Researcher", llm=llm, ...)
# All crew workflows work unchanged

LlamaIndex

from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="deepseek-v4",
    api_base="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    api_key="ait-your-key-here",
)
# All RAG pipelines work unchanged

What Works Out of the Box

โœ… Fully Compatible:

Known Differences

โš ๏ธ Minor Differences to Be Aware Of:

Testing Checklist

Before going to production:
  1. Test your core prompts โ€” verify output quality matches expectations
  2. Test function calling โ€” ensure tool schemas are parsed correctly
  3. Test streaming โ€” verify SSE events work in your framework
  4. Test error handling โ€” try invalid inputs, check error format
  5. Load test โ€” verify latency meets your requirements
  6. Monitor costs โ€” compare first week's bill vs OpenAI

Cost Savings After Migration

Your Current UsageOpenAI CostAI Token Hub CostYou Save
1M tokens/day (GPT-4o)~$75/week~$15/week$60/week
10M tokens/day (GPT-4o-mini)~$42/week~$5/week$37/week
100K tokens/day (o1-mini)~$21/week~$4/week (R1)$17/week
Ready to migrate? Start free today.
100 free requests/day. No credit card. OpenAI-compatible API.
Get API Key โ†’