> ## Documentation Index
> Fetch the complete documentation index at: https://www.edenai.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Fallback

> Eden AI automatically handles fallback on both LLM and Universal AI / expert model requests.

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={"Fallback"} description={"Eden AI automatically handles fallback on both LLM and Universal AI / expert model requests."} path="v3/general/fallback" articleSection="General" about={"API Configuration"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "rate limits", "billing", "monitoring"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

Eden AI automatically handles fallback on both LLM and Universal AI / expert model requests. If your primary model or provider fails (provider outage, rate limit, error), Eden AI retries with the next item in your `fallbacks` list -- no retry logic needed on your side.

## Usage

Add a `fallbacks` array to your request with one or more backup models (LLM) or providers (expert models). If the primary `model` fails, Eden AI will try each fallback in order.

<Tabs>
  <Tab title="LLMs">
    <Info>
      All models (primary and fallbacks) must be valid models listed in the [Models](/v3/llms/listing-models) page.
    </Info>

    <CodeGroup>
      ```python Python theme={null}
      import requests

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

      payload = {
          "model": "google/gemini-2.5-pro",
          "fallbacks": ["openai/gpt-4o"],
          "messages": [
              {"role": "user", "content": [{"type": "text", "text": "hi"}]}
          ],
          "reasoning_effort": "none",
      }

      response = requests.post(url, headers=headers, json=payload)

      print(response.status_code)
      print(response.json())
      ```

      ```bash cURL theme={null}
      curl -X POST https://api.edenai.run/v3/chat/completions \
        -H "Authorization: Bearer YOUR_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "google/gemini-2.5-pro",
          "fallbacks": ["openai/gpt-4o"],
          "messages": [{"role": "user", "content": [{"type": "text", "text": "hi"}]}],
          "reasoning_effort": "none"
        }'
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Expert Models">
    <Info>
      All providers (primary and fallbacks) must support the same feature and subfeature. Use the [Listing Models](/v3/expert-models/listing-models) endpoint to discover available providers.
    </Info>

    <CodeGroup>
      ```python Python theme={null}
      import requests

      url = "https://api.edenai.run/v3/universal-ai"
      headers = {
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      }

      payload = {
          "model": "text/moderation/microsoft",
          "fallbacks": ["text/moderation/google"],
          "input": {"text": "Text to moderate"}
      }

      response = requests.post(url, headers=headers, json=payload)

      print(response.status_code)
      print(response.json())
      ```

      ```javascript JavaScript theme={null}
      const response = await fetch("https://api.edenai.run/v3/universal-ai", {
        method: "POST",
        headers: {
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          model: "text/moderation/microsoft",
          fallbacks: ["text/moderation/google"],
          input: { text: "Text to moderate" }
        })
      });

      console.log(response.status);
      console.log(await response.json());
      ```

      ```bash cURL theme={null}
      curl -X POST https://api.edenai.run/v3/universal-ai \
        -H "Authorization: Bearer YOUR_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "text/moderation/microsoft",
          "fallbacks": ["text/moderation/google"],
          "input": {"text": "Text to moderate"}
        }'
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
  <Card title="LLM Models" icon="brain" href="/v3/llms/listing-models">
    Browse available LLM models
  </Card>

  <Card title="Expert Model Providers" icon="microchip" href="/v3/expert-models/listing-models">
    Discover available providers for each feature
  </Card>
</CardGroup>
