DEV Community

vvvvking
vvvvking

Posted on

One OpenAI-compatible API for DeepSeek, Qwen, and Chinese image/video models

If you build with LLMs, you already have OpenAI-compatible code lying around. The nice thing about that format is you can point the same code at almost any provider by swapping base_url. What most guides skip is that the Chinese frontier models — DeepSeek, Qwen, Kimi, GLM, Doubao, MiniMax, Hunyuan — and their image and video siblings can be reached the exact same way.

This is a short, practical walkthrough of calling text, image, and video models from one OpenAI-compatible endpoint, with copy-paste code you can run in a minute. I'll use NovAI as the gateway (disclosure: it's the service I work on), but the patterns apply to any OpenAI-compatible endpoint.

Why one endpoint matters

If you want DeepSeek for reasoning, Qwen for multilingual, Seedream for images, and Seedance for short video, the naive path is four SDKs, four auth schemes, four billing dashboards. A single OpenAI-compatible gateway collapses that to one base_url + one key. Fewer moving parts, and your existing OpenAI code keeps working.

1. Chat — drop-in OpenAI SDK

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_KEY",
    base_url="https://aiapi-pro.com/v1",
)

resp = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Explain mixture-of-experts in one paragraph."}],
)
print(resp.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Streaming is the standard stream=True iterator — nothing special. Swap model for qwen3.7-max, glm-5.2, kimi-k2.6, minimax-m3, doubao-seed-2.0-pro, etc.

2. Image — Doubao Seedream 5.0

Image generation follows the OpenAI images.generate shape:

img = client.images.generate(
    model="doubao-seedream-5.0",     # or -pro
    prompt="a red panda coding on a laptop, studio ghibli style, warm light",
    size="2048x2048",
    n=1,
)
print(img.data[0].url)
Enter fullscreen mode Exit fullscreen mode

Seedream likes large sizes — go with 2048x2048 rather than the classic 1024x1024.

3. Video — Doubao Seedance 2.0 (async)

Video is the one place the flow differs: generation takes time, so you submit a job and poll.

import requests, time

BASE = "https://aiapi-pro.com/v1"
H = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}

job = requests.post(f"{BASE}/video/generations", headers=H, json={
    "model": "doubao-seedance-2.0",          # or -fast
    "prompt": "a paper plane flying over a neon city at night, cinematic",
    "resolution": "720p",
    "duration": 5,
}).json()

task_id = job["id"]
while True:
    r = requests.get(f"{BASE}/video/generations/{task_id}",
                     headers=H, params={"model": "doubao-seedance-2.0"}).json()
    if r.get("status") == "succeeded":
        print("video:", r["content"]["video_url"])
        break
    if r.get("status") == "failed":
        raise RuntimeError(r)
    time.sleep(4)
Enter fullscreen mode Exit fullscreen mode

That's the whole surface: chat, image, video, same key.

A note on pricing (the honest version)

I won't pretend a gateway is magically cheapest across the board — that's rarely true and easy to disprove. From the current published numbers, some models come out clearly ahead of other aggregators (Qwen3.7-Max lands ~45% cheaper, Doubao-Seed-2.0-Lite ~53% cheaper than OpenRouter), some are effectively at parity (DeepSeek-V4-Pro), and a few are more expensive. The real win here isn't a price war — it's one API for text + image + video across every major Chinese lab, which the text-only aggregators don't cover. Always check live numbers before you commit.

Try it

If you're already writing OpenAI-compatible code, adding Chinese text/image/video models is a base_url change away. Happy building.


Disclosure: I work on NovAI, the gateway used in the examples. Written with AI assistance for drafting; all code was verified against the live API.

Top comments (0)