All posts

Migrating from OpenAI to DeepSeek: a painless, OpenAI-compatible switch

· Migration· DeepSeek· OpenAI-compatible

If you're paying GPT-5.5 rates ($5 input / $30 output per million tokens) for work that DeepSeek V4-Pro does just as well at a fraction of the output price, migrating is one of the highest-ROI changes you can make. And because DeepSeek is reachable through an OpenAI-compatible endpoint, the migration really is two lines.

The whole change: base URL and model name

Your existing OpenAI code stays exactly the same. You only repoint the client and change the model string.

Before (OpenAI):

from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

r = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": prompt}],
)

After (DeepSeek via Turiloop):

from openai import OpenAI
client = OpenAI(
    api_key=os.environ["TURILOOP_API_KEY"],
    base_url="https://api.turiloop.com/v1",
)

r = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": prompt}],
)

Everything downstream stays unchanged: r.choices[0].message.content, streaming, tool calls, and the messages shape. The endpoint follows the OpenAI spec.

What carries over, and what to check

  • Chat, streaming, system/user/assistant roles: identical.
  • Tool and function calling: supported, but verify your tool schemas behave the same on the new model.
  • `max_tokens`, `temperature`, `top_p`: standard params carry over.
  • Vision and image inputs: check per model; for image *generation*, use the dedicated image endpoint.

The cost math

For a workload doing 50M input and 10M output tokens per month:

  • GPT-5.5: 50 × $5 + 10 × $30 = $550 / month.
  • DeepSeek V4-Pro ($0.435 / $0.87): 50 × $0.435 + 10 × $0.87 ≈ $30 / month.

That's about a 95% cut for comparable coding quality. Push the easy traffic to V4-Flash and the bill drops further.

A safe migration plan

  1. Shadow: send a sample of real traffic to deepseek-v4-pro in parallel and compare outputs.
  2. Route the easy stuff first: move classification and extraction to deepseek-v4-flash.
  3. Cut over the rest: once outputs check out, flip the default model.
  4. Keep a fallback: the same key reaches claude-opus-4-8 if a specific prompt needs the closed frontier.

Because it's all one OpenAI-compatible key on Turiloop, each step is a model-string change, not an integration. Paid pay-as-you-go with an international card, no Chinese phone number needed.