DEV Community

Dubhe
Dubhe

Posted on

How to Switch From OpenAI to a Multi-Model AI API in 5 Minutes

If you're like most developers, you probably started with OpenAI's API. It's the default choice — great documentation, solid models. But as your project grows, you might notice some friction:

  • Costs add up fast. A single chat-heavy app can burn through hundreds of dollars.
  • No fallback. If OpenAI goes down, your app goes down.
  • One model doesn't fit all. Sometimes you need a fast model for simple queries and a reasoning model for complex tasks.

Powered by some of the most advanced AI models from China's leading labs — giving you enterprise-grade performance at a fraction of the usual cost.

The solution? A multi-model API gateway that gives you access to multiple providers through a single OpenAI-compatible endpoint.

What You'll Need

  • An API key from Dubhe Hub (free tier includes 100K tokens)
  • Any OpenAI SDK (Python, Node.js, curl — they all work)

Step 1: Get Your API Key

Go to dubhehub.com, sign up, and create an API key. The dashboard shows you six models to choose from.

Step 2: Make Your First Call

Here's a Node.js example. Notice that the code looks exactly like OpenAI's SDK:

import OpenAI from 'openai';

const dubhe = new OpenAI({
  baseURL: 'https://dubhehub.com/v1',
  apiKey: 'your-key-here'
});

// Fast model for quick responses
const quick = await dubhe.chat.completions.create({
  model: 'dubhe-fast',
  messages: [{ role: 'user', content: 'Explain REST APIs in 3 bullet points' }]
});
console.log(quick.choices[0].message.content);
Enter fullscreen mode Exit fullscreen mode

Step 3: Swap Models Without Changing Code

The real power is switching models by changing just the model name:

// Use dubhe-reasoning for complex logic
const analysis = await dubhe.chat.completions.create({
  model: 'dubhe-reasoning', 
  messages: [{ role: 'user', content: 'Write a debounce function in TypeScript' }]
});

// Use dubhe-vision for image analysis
const vision = await dubhe.chat.completions.create({
  model: 'dubhe-vision',
  messages: [
    { role: 'user', content: [
      { type: 'text', text: 'What's in this image?' },
      { type: 'image_url', image_url: { url: 'https://example.com/photo.jpg' } }
    ]}
  ]
});
Enter fullscreen mode Exit fullscreen mode

Model Overview

Model Best For Input/1M tokens Output/1M tokens Context
dubhe-fast General chat, text $0.30 $0.60 1M
dubhe-code Programming tasks $0.80 $3.00 200K
dubhe-agent Automation, agents $1.00 $4.00 205K
dubhe-plus Long context, analysis $2.00 $8.00 1M
dubhe-vision Image understanding $5.00 $15.00 1M
dubhe-reasoning Deep reasoning $6.00 $18.00 1M

Why Multi-Model?

  1. Cost optimization: Use cheap models for simple tasks, expensive ones only when needed
  2. Provider diversity: If one provider has an outage, switch to another instantly
  3. Performance matching: Match model capability to task complexity

The migration takes about 5 minutes — just change the baseURL and apiKey. Everything else (streaming, function calling, embeddings) works the same way.

Try it yourself at dubhehub.com.

Top comments (0)