Claude, GPT and Gemini are temporarily unavailable on AIPower.

Smart Routing

One call, the right model.

Stop hardcoding one model for every request.

Use model="auto" and let AIPower pick, fail over, and log the route.

Try routing β€” 10 trial calls

How it works in 1 line of code:

response = client.chat.completions.create(
    model="deepseek/deepseek-chat", # ← choose an available Chinese model
    messages=[{"role":"user", "content":"Refactor this function..."}],
)

No change to request / response shape. The modelfield in the response shows which model actually ran, so you can track cost & quality per route.

Available routing modes

Each mode targets a different optimization goal.

General chat / most tasks

model="auto"

🎯

Routes to: DeepSeek V3

Goal: Balance of cost & quality

Cost: ~$0.35/M

Default choice when you don't know which to pick

Batch processing, classification

model="auto-cheap"

πŸ’°

Routes to: Doubao Pro 256K

Goal: Cost control for routine work

Cost: ~$0.08/M

Classify high-volume messages without hardcoding a premium model

Realtime chat, suggestions, autocomplete

model="auto-fast"

⚑

Routes to: Qwen Turbo

Goal: Fastest time-to-first-token

Cost: ~$0.15/M

Live chatbot where latency > quality

Demos, experiments, dev scripts

model="auto-free"

✨

Routes to: GLM-4 Flash

Goal: Utility workload routing

Cost: ~$0.01/M

Prompt engineering experiments and demos

Real cost math β€” 1M requests/day app

Assume 500 input tokens + 200 output per request (typical chatbot). Here's what you'd pay.

StrategyCost / dayCost / month
Only DeepSeek V3$310$9,300

Spend control comes from sending routine tasks to efficient models and reserving premium models for where they matter.

Automatic failover

If your primary model returns 5xx, we fall back to a different provider β€” same request, different upstream. Transparent to your app.

# Illustrative failover chain; not live gateway configuration
FALLBACK = {
  deepseek:  [qwen-plus],
  qwen:      [deepseek-chat],
  ...
}

# Your code stays 1 line:
client.chat.completions.create(
    model="deepseek/deepseek-chat",
    messages=[...])
# On an upstream error, an available backup may be used.
# Transparent, logged.

"Why not just build this myself?"

You could. But you'd have to:

  • β€’ Maintain accounts with multiple providers (DeepSeek, Alibaba, Zhipu, Moonshot, MiniMax, ByteDance)
  • β€’ Handle different API formats (OpenAI-compat is not universal)
  • β€’ Keep track of when each provider's pricing / rate limits change
  • β€’ Monitor uptime per provider and update fallback logic
  • β€’ Track which model is best per task-type (benchmarks shift quarterly)
  • β€’ Build dashboards for per-model cost/latency observability

Or use AIPower:

  • β€’ One account, one API key
  • β€’ OpenAI SDK compatible (change 1 line)
  • β€’ Pricing updated weekly in the platform
  • β€’ Failover built-in
  • β€’ Smart routing by scenario
  • β€’ /dashboard/analytics shows you everything

Routing, failover, pricing updates, and analytics are included in the managed gateway instead of becoming another internal DevOps project.

Full code example

from openai import OpenAI

client = OpenAI(
    base_url="https://api.aipower.me/v1",
    api_key="sk-your-aipower-key",
)

def smart_ask(task_type: str, messages: list):
    """Route based on task type."""
    route_map = {
        "chat":      "auto",            # DeepSeek V3 β€” balanced
        "batch":     "auto-cheap",      # Doubao Pro β€” cost-control route
        "realtime":  "auto-fast",       # Qwen Turbo β€” fastest
        "demo":      "auto-free",       # GLM-4 Flash β€” utility route
    }
    return client.chat.completions.create(
        model=route_map.get(task_type, "auto"),
        messages=messages,
    )

# Usage
bulk_classification  = smart_ask("batch", [...])   # routine route
live_chat_response   = smart_ask("realtime", [...]) # low-latency route

Route by workload, not guesswork.

One API key. 10 models. Available routing modes. Usage logs and failover included.

Also: docs / analytics / in-depth blog