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

# Chat

> OpenRouter Chat API examples: basic agents, ordered model fallback, retries, structured output, and tool use.

Use [OpenRouter's Chat API](https://openrouter.ai/docs/sdks/python/api-reference/chat) to reach multiple models through one endpoint. Give an agent an ordered fallback list so a request that hits a rate limit, timeout, or overload retries on the next model.

For details, see examples in `cookbook/90_models/openrouter/chat`.

| Example                                                                       | Description                                                                                                                          |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [Basic](/examples/models/openrouter/chat/basic)                               | Run a minimal OpenRouter agent with sync, streaming, and async response variants.                                                    |
| [Dynamic Model Router](/examples/models/openrouter/chat/dynamic-model-router) | Dynamic models provide automatic failover when the primary model encounters rate limits, timeouts, unavailability or model overload. |
| [Retry](/examples/models/openrouter/chat/retry)                               | Review retry settings and why invalid model IDs cannot reliably exercise the retry path.                                             |
| [Structured Output](/examples/models/openrouter/chat/structured-output)       | Compare JSON mode and native structured outputs on OpenRouter by generating a MovieScript Pydantic model.                            |
| [Tool Use](/examples/models/openrouter/chat/tool-use)                         | Give an OpenRouter agent WebSearchTools and stream the answer in both sync and async runs.                                           |
