> ## Documentation Index
> Fetch the complete documentation index at: https://edenai-docs-github-copilot-integration.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Learn practical patterns for implementing smart routing with LLMs using Eden AI's dynamic model selection.

# Smart routing

export const TechArticleSchema = ({title, description, path, articleSection, about, proficiencyLevel = "Beginner", dependencies, keywords = [], datePublished, dateModified, image, inLanguage = "en"}) => {
  const baseUrl = "https://www.edenai.co/docs";
  const canonicalUrl = `${baseUrl}/${path}`.replace(/\/+$/, "");
  const ogParams = new URLSearchParams({
    division: articleSection || "",
    title: title || "",
    description: description || ""
  });
  const resolvedImage = image || `https://edenai.mintlify.app/_mintlify/api/og?${ogParams.toString()}`;
  const data = {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "@id": `${canonicalUrl}#techarticle`,
    mainEntityOfPage: {
      "@type": "WebPage",
      "@id": canonicalUrl
    },
    headline: title,
    name: title,
    description: description,
    url: canonicalUrl,
    inLanguage: inLanguage,
    isPartOf: {
      "@type": "WebSite",
      name: "Eden AI Documentation",
      url: baseUrl
    },
    author: [{
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/"
    }],
    publisher: {
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/",
      logo: {
        "@type": "ImageObject",
        url: "https://www.edenai.co/assets/logo.png"
      }
    }
  };
  if (articleSection) data.articleSection = articleSection;
  if (about) data.about = {
    "@type": "Thing",
    name: about
  };
  if (proficiencyLevel) data.proficiencyLevel = proficiencyLevel;
  if (dependencies) data.dependencies = dependencies;
  if (keywords && keywords.length) data.keywords = keywords;
  if (datePublished) data.datePublished = datePublished;
  if (dateModified) data.dateModified = dateModified;
  data.image = Array.isArray(resolvedImage) ? resolvedImage : [resolvedImage];
  const json = JSON.stringify(data);
  const schemaId = `techarticle-${canonicalUrl}`;
  React.useEffect(() => {
    if (typeof document === "undefined") return;
    document.querySelectorAll(`script[data-schema-id="${schemaId}"]`).forEach(n => n.remove());
    const script = document.createElement("script");
    script.type = "application/ld+json";
    script.dataset.schemaId = schemaId;
    script.textContent = json;
    document.head.appendChild(script);
    return () => script.remove();
  }, [json, schemaId]);
  return null;
};

<TechArticleSchema title={"Smart Routing"} description={"Learn practical patterns for implementing smart routing with LLMs using Eden AI's dynamic model selection."} path="v3/llms/smart-routing" articleSection="LLMs" about={"LLM API"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "LLM API", "chat completion", "OpenAI compatible"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

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.

## Basic Usage

Let the system choose from all available models:

```python Python theme={null}
import requests

url = "https://api.edenai.run/v3/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 Python theme={null}
import requests

url = "https://api.edenai.run/v3/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 Case             | Recommended Candidates                          | Notes                 |
| -------------------- | ----------------------------------------------- | --------------------- |
| **General chat**     | gpt-4o, claude-sonnet-4-5, gemini-2.5-flash     | Balanced quality/cost |
| **Code generation**  | gpt-4o, claude-sonnet-4-5                       | Strong coding models  |
| **Creative writing** | claude-opus-4-5, gpt-4o, gemini-2.5-pro         | Premium models        |
| **Simple Q\&A**      | gpt-4o-mini, gemini-2.5-flash, claude-haiku-4-5 | Fast and cheap        |
| **Function calling** | gpt-4o, claude-sonnet-4-5, gemini-2.5-flash     | Tool-compatible       |

## Next Steps

<CardGroup cols={2}>
  <Card title="Fallback" icon="rotate-left" href="/v3/general/fallback">
    Built-in fallback for LLM and expert model requests
  </Card>
</CardGroup>

* **[Streaming Guide](./streaming)** - Handle SSE responses
