DEV Community

TokenHub
TokenHub

Posted on

How to Switch from OpenAI to DeepSeek in 5 Lines of Code

Before (OpenAI)

from openai import OpenAI
client = OpenAI(api_key="sk-your-key")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a Python function"}]
)
After (DeepSeek via TokenHub)

from openai import OpenAI
client = OpenAI(base_url="https://t-hub.cc/v1", api_key="sk-your-token")
response = client.chat.completions.create(
model="deepseek-v3",
messages=[{"role": "user", "content": "Write a Python function"}]
)
Three changes. Zero refactoring. Same OpenAI SDK.

DeepSeek is 10x cheaper AND scores higher on coding benchmarks. The only catch is the Chinese phone requirement — TokenHub solves that.

Try it: https://t-hub.cc

Top comments (0)