What are Direct API Requests?
Direct API requests mean making HTTP calls directly to Model Router’s endpoints using tools like cURL, Postman, or any HTTP client library. This is the most straightforward way to interact with the API.Before You Start
Before making requests, check which models are available to your API key by calling the model list endpoint.
API Base URL
All requests should be sent to:Authentication
Include your API key in theAuthorization header:
Request Examples
OpenAI-Compatible Endpoint
The/v1 endpoint works with OpenAI-style requests. This is the most common way to use Model Router.
Replace
sk-demo123 with your actual API key. Replace gpt-4o-mini with a model that’s available to your API key. Check the model list to see available models.Streaming Responses
To get streaming responses, setstream to true:
Claude Native Endpoint
If you’re using Claude models, you can use the native Claude endpoint:Gemini Native Endpoint
For Gemini models, use the native Gemini endpoint:Important Notes
- Check Available Models: Always check which models are available to your API key before making requests. See List Available Models.
- Model Names: Use the exact model ID from the model list. Different API keys may have access to different models.
-
Error Handling: If you get an error, check:
- Is your API key correct?
- Is the model available to your API key?
- Do you have sufficient quota?
- See Error Handling for more help.
- View Usage: After making requests, you can view your usage and billing in the console.