DEV Community

Jeffrey.Feillp
Jeffrey.Feillp

Posted on

Multi-Model Manager

You have GPT-4 for reasoning, Claude for coding, DeepSeek for cost efficiency, and a local llama.cpp for privacy-sensitive data.

But each one needs a different API client, different auth, different message format. Switching between them is a pain.

Tian AI Agent 14.0 solves this with a unified model manager:

# Add any model backend
POST /api/config {"action":"add", "name":"gpt4", "endpoint":"https://api.openai.com/v1", "api_key":"sk-..."}
POST /api/config {"action":"add", "name":"claude", "endpoint":"https://api.anthropic.com/v1", "api_key":"sk-ant-..."}
POST /api/config {"action":"add", "name":"local", "endpoint":"http://localhost:8080"}

# Switch between them instantly
POST /api/config {"action":"switch", "name":"local"}
Enter fullscreen mode Exit fullscreen mode

What's Supported

Provider Protocol Capabilities
OpenAI OpenAI-compat chat, image, audio, embedding, video
Anthropic Claude Anthropic native chat
DeepSeek OpenAI-compat chat
Google Gemini Gemini native chat, image
xAI Grok OpenAI-compat chat
Mistral OpenAI-compat chat
Groq OpenAI-compat chat
OpenRouter OpenAI-compat chat, image
Stability AI OpenAI-compat image
Runway OpenAI-compat video
ElevenLabs OpenAI-compat audio
llama.cpp Completion API chat
Ollama Ollama native chat, embedding
Any OpenAI-compatible Auto-detected chat

Auto Protocol Detection

Just paste the endpoint URL — the tool figures out the format:

from model_manager import ModelConnector
mc = ModelConnector(endpoint="https://api.anthropic.com/v1", api_key="sk-ant-...")
mc.chat([{"role": "user", "content": "Hello"}])
# → Automatically uses Anthropic's /v1/messages format
Enter fullscreen mode Exit fullscreen mode

It works by:

  1. Checking known domains (openai.com → OpenAI format, anthropic.com → Anthropic format, etc.)
  2. Probing the endpoint for common API paths (/v1/chat/completions, /api/chat, /completion)
  3. Falling back to OpenAI-compatible format for unknown endpoints

Multi-Model Routing

The ModelManager keeps all your models in one place. When you send a request, it routes to the right model based on capability:

mm = ModelManager()
mm.add("gpt4", endpoint="https://api.openai.com/v1", api_key="sk-...", 
       capabilities=["chat", "image", "embedding"])
mm.add("sdxl", endpoint="https://api.stability.ai", api_key="sk-...",
       capabilities=["image"])

# Chat goes to GPT-4
mm.chat("Hello")

# Image generation auto-routes to Stability AI
mm.generate_image("A cat in a spacesuit")
Enter fullscreen mode Exit fullscreen mode

Web UI Included

Launch python3 tian_ai_agent_14.0.pyz --web 8080 for a browser interface where you can add/switch/remove models on the fly.

Free. No Registration. 77KB.

Download the single .pyz file and run it anywhere with Python 3.10+.

Top comments (0)