This guide shows how to use Perplexity’s Agent API as a unified gateway to models from OpenAI, Anthropic, Google, xAI, and Perplexity — all through a single API key with zero markup. You will learn how to route to specific providers, build fallback chains for high availability, compare responses across models, and dynamically discover available models via theDocumentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
/v1/models endpoint.
Perplexity passes through third-party model usage at cost with no markup. You pay only what the provider charges, consolidated on a single bill. See Models for the full list.
Prerequisites
Install the Perplexity SDK:Get your Perplexity API Key
Navigate to the API Keys tab in the API Portal and generate a new key.
Why Multi-Provider?
| Benefit | Details |
|---|---|
| Single API key | Access OpenAI, Anthropic, Google, xAI, and Perplexity models without separate accounts |
| Zero markup | Third-party model costs are passed through at provider pricing |
| Unified format | Same request/response format across all providers |
| Built-in fallback | The models parameter tries providers in order until one succeeds |
| Tool compatibility | web_search, fetch_url, and custom functions work with all models |
Available Models
Use the/v1/models endpoint to discover all available models dynamically.
| Provider | Models | Best For |
|---|---|---|
| OpenAI | openai/gpt-5.4, openai/gpt-5.1, openai/gpt-5-mini, openai/gpt-5.4 | General reasoning, code, analysis |
| Anthropic | anthropic/claude-opus-4-6, anthropic/claude-sonnet-4-6, anthropic/claude-haiku-4-5 | Long context, instruction following |
google/gemini-3.1-flash-lite, google/gemini-3.1-pro-preview | Multimodal, fast inference | |
| xAI | xai/grok-4-1-fast-non-reasoning | Fast responses, conversational |
| Perplexity | perplexity/sonar | Search-grounded answers |
Routing to a Specific Provider
Use themodel parameter to target a specific provider’s model.
Model Fallback Chains
Themodels parameter accepts an array of up to 5 models. The API tries each in order and returns the first successful response. This is ideal for production systems where availability matters.
Comparing Responses Across Providers
Send the same prompt to multiple models and compare quality, latency, and cost.Task-Based Model Routing
Different tasks suit different models. Build a router that picks the best model for each task type.Combining Multi-Provider with Tools
All models accessed through the Agent API support the same tool interface —web_search, fetch_url, and custom functions work identically regardless of provider.
Dynamic Model Discovery
Build applications that automatically adapt to newly available models by querying the/v1/models endpoint at startup.
The
/v1/models endpoint returns the current list of supported models. Query it at application startup or cache it with a TTL to stay current as new models are added.Next Steps
Models
Full list of available models, capabilities, and pricing.
Model Fallback
Deep dive into fallback chain configuration and behavior.
Model Comparison Example
CLI tool for benchmarking models side-by-side.
Presets
Use presets like
pro-search for optimized defaults.