Nexevo.aiNexevo.ai
← All examples
Nexevo exclusive capabilities

Automatic fallback for multiple models

Pass a `models: [...]` list and the agent will try one by one until it succeeds - built-in fault tolerance.

python
# Nexevo-specific extension: try multiple models in order.
# Failover is handled server-side — one HTTP call, multiple chances of success.

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NEXEVO_API_KEY"],
    base_url="https://api.nexevo.ai/v1",
)

response = client.chat.completions.create(
    extra_body={"role": "user", "content": "Hello!"},
    messages=[{"role": "user", "content": "Hello!"}],
)

# Check which model actually served:
print(response.headers.get("x-nexevo-model-used"))
print(response.headers.get("x-nexevo-models-tried"))
Automatic fallback for multiple models — Nexevo Cookbook | Nexevo.ai