Model Routing in Python
A practical guide to reducing AI costs by routing tasks to appropriate models.
Simple Example
from openai import OpenAI
client = OpenAI(base_url="https://api.tunanapi.com/v1", api_key="your-key")
# Route based on task complexity
def complete(prompt, complexity="simple"):
model = {"simple": "glm-4-flash", "complex": "deepseek-v4-pro"}[complexity]
return client.chat.completions.create(model=model, messages=[{"role": "user", "content": prompt}])
Get started at https://tunanapi.com
Top comments (0)