DEV Community

Cover image for OpenAI SDK DeepSeek / Qwen / GLM without rewriting your app
XLB223
XLB223

Posted on

OpenAI SDK DeepSeek / Qwen / GLM without rewriting your app

Problem

I wanted to try Chinese LLMs (DeepSeek, Qwen, GLM) without maintaining multiple SDKs.
I wanted to try Chinese LLMs (DeepSeek, Qwen, GLM) without maintaining three different SDKs.

Approach

Use an OpenAI-compatible gateway. Keep your existing client; change base URL + API key.
If your stack already speaks OpenAI, you can keep the same client and only change:

  • base_url
  • api_key
  • model That's what I use API Hub for: an OpenAI-compatible endpoint. ## Quick start
  • Sign up at https://apihub4u.com (trial credits on signup)
  • Create an API key
  • Point your SDK to: https://apihub4u.com/v1
  • Set model to e.g. deepseek-chat or qwen-turbo ## Example (Python)
  • Sign up at apihub4u.com (trial credits on signup)
  • Create an API key in the dashboard
  • Point your SDK to https://apihub4u.com/v1
  • Pick a model, e.g. deepseek-chat or qwen-turbo ## Python example
from openai import OpenAI
client = OpenAI(
resp = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Hello"}],
    messages=[{"role": "user", "content": "Hello! Give me one productivity tip."}],
)
print(resp.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Notes

Why this helped me

  • One integration path for multiple models
  • Switch providers by changing the model field
  • Streaming works (SSE)
  • Prices are listed on the dashboard / docs
  • Prices are listed on the dashboard/docs
  • Overseas top-ups via PayPal Docs: https://apihub4u.com/docs.html Docs: apihub4u.com/docs.html If you're prototyping or running a small product, this cuts a lot of glue code. Feedback welcome.

Top comments (0)