Skip to main content

How Routing Works

YouRouter offers two modes for routing your API requests: automatic and manual. This behavior is controlled by the vendor header.

Default Behavior: Automatic Routing (auto)

For maximum reliability, we recommend using our automatic routing mode. This is the default behavior if you omit the vendor header or set it to auto. In auto mode, YouRouter intelligently routes your request to the most available and cost-effective provider for the requested model. For example, if you request gpt-4o and OpenAI’s API is experiencing latency, we will seamlessly failover to another provider like Azure OpenAI to ensure your request is processed without interruption. This is the ideal setting for production applications where high availability is critical.

Manual Routing: Specifying a Provider

If you need to use a specific model from a particular provider or access a provider-exclusive feature, you can manually route your request. To do this, simply set the vendor header to the desired provider’s ID. For instance, to guarantee your gpt-4o request is handled by Azure, you would include vendor: azure in your request header.
from openai import OpenAI

client = OpenAI(
    api_key="your-api-key-here",
    base_url="https://api.yourouter.ai/v1"
)

# Pin the request to a specific provider (e.g., Azure)
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello from Azure OpenAI!"}],
    extra_headers={"vendor": "azure"}
)

print(response.choices[0].message.content)

Available Providers

Providervendor Value
Anthropicanthropic
AWS Bedrockaws
Azure OpenAIazure
DeepSeekdeepseek
Googlegoogle
Mistral AImistral
OpenAIopenai
Volcenginevolcengine
xAIx

Zero Completion Insurance

Our fair billing policy ensures you only pay for successful, non-empty responses. You will not be charged for requests that result in an error (e.g., a 500 status code) or return zero completion tokens. This is our Zero Completion Insurance, and it’s enabled by default on all requests.

Best Practices

  • Use auto for Production: For any application where uptime is important, we strongly recommend using the default auto mode to benefit from our automatic failover and high-availability routing.
  • Use Manual Routing for Specific Needs: If you require a model or feature unique to one provider, specify the provider using the vendor header.
  • Consult Provider-Specific Docs: When using manual routing to access special features, always refer to the native provider’s documentation for detailed parameter information. You can pass these parameters directly through YouRouter, as explained in our Request Forwarding guide.
See our Chat Completions guide for more detailed API examples.
I