https://api.yourouter.ai/v1, so most existing OpenAI SDK integrations only need a base URL and API key change.
Need an API key? Create one in the YouRouter Dashboard.
Integration Basics
1. Set Your API Key
Store your API key in an environment variable before running the examples below.- macOS/Linux
- Windows
- .env
2. Make a Test Request
The fastest integration smoke test is a direct HTTP request to the Chat Completions endpoint. A successful response includeschoices[0].message.content. Use cURL or any standard HTTP client; the examples below cover Python, Node.js, Go, Java, PHP, and Rust.
- cURL
- Python requests
- Node.js 18+ fetch
- Go
- Java 11+
- PHP
- Rust
3. Migrate Existing OpenAI SDK Code
If your app already uses the OpenAI SDK, keep your request body shape and update two fields:api_key and base_url.
- Python
- Node.js
For Go, Java, PHP, and Rust, use the same custom base URL pattern when your OpenAI-compatible SDK supports it. If the SDK does not expose a base URL option, call the
/v1/chat/completions endpoint directly with the HTTP examples above.4. Choose a Model and Route
Choose a model by setting themodel field. You can call many model families through the same API shape, such as OpenAI GPT models, Claude, Gemini, DeepSeek, Grok, Doubao, and Kimi. For vision and other multimodal inputs, see the Multimodal guide.
If an example model is not enabled for your account, replace it with any available model ID from the YouRouter Dashboard.
vendor header, or set vendor: auto, when you want YouRouter to choose the best available provider for the requested model.
Pin a request to a provider only when your integration depends on a specific upstream behavior, model variant, account, or compliance path.
- cURL
- Python SDK
- Node.js SDK
5. Handle Responses and Errors
For OpenAI-compatible endpoints, successful responses follow the OpenAI response format. Read generated text fromchoices[0].message.content.
6. Stream Responses
For chat UIs and agents, setstream to true to receive incremental chunks as the model generates text.
Next Steps
API Reference
Review endpoints, parameters, and response formats.
Models
See how to pass model IDs and switch models through the API.
Multimodal
Send image inputs and call provider-native multimodal APIs.
Router Guide
Learn when to use automatic routing or pin a provider.
Chat Completions
Build conversations, streaming UIs, tools, and multimodal flows.