Skip to main content
Learn practical patterns for implementing smart routing with LLMs using Eden AI’s dynamic model selection.

Overview

Use @edenai as the model name to let the router automatically select the best available model. You can optionally provide router_candidates to restrict selection to a specific pool. Related documentation:

Basic Usage

Let the system choose from all available models:
Python
import requests

url = "https://api.edenai.run/v3/llm/chat/completions"
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json={
    "model": "@edenai",
    "messages": [{"role": "user", "content": "Explain machine learning"}]
})

print(response.json()['choices'][0]['message']['content'])

Custom Candidate Pool

Restrict routing to a specific set of models using router_candidates:
Python
import requests

url = "https://api.edenai.run/v3/llm/chat/completions"
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json={
    "model": "@edenai",
    "router_candidates": [
        "openai/gpt-4o",
        "anthropic/claude-sonnet-4-5",
        "google/gemini-2.5-flash"
    ],
    "messages": [{"role": "user", "content": "Write a Python function to merge two sorted lists"}]
})

print(response.json()['choices'][0]['message']['content'])

Use Case Reference

Use CaseRecommended CandidatesNotes
General chatgpt-4o, claude-sonnet-4-5, gemini-2.5-flashBalanced quality/cost
Code generationgpt-4o, claude-sonnet-4-5Strong coding models
Creative writingclaude-opus-4-5, gpt-4o, gemini-2.5-proPremium models
Simple Q&Agpt-4o-mini, gemini-2.5-flash, claude-haiku-4-5Fast and cheap
Function callinggpt-4o, claude-sonnet-4-5, gemini-2.5-flashTool-compatible

Next Steps