is openrouter api compatiple to openai api ?
- User
is openrouter api compatiple to openai api ?
Assistant
Yes, OpenRouter's API is designed to be compatible with OpenAI's API format. This means you can generally use OpenRouter as a drop-in replacement for OpenAI by:
- Changing the base URL from
https://api.openai.com/v1tohttps://openrouter.ai/api/v1 - Using your OpenRouter API key instead of your OpenAI key
- Specifying the model you want to use (OpenRouter provides access to many different models, not just OpenAI's)
Most OpenAI client libraries and code that uses the OpenAI API format should work with OpenRouter with minimal changes. The request and response formats are intentionally kept compatible to make switching between providers easier.
The main differences you might encounter are:
- Model names (you'll need to use OpenRouter's model identifiers)
- Some provider-specific parameters or features might not be available
- Pricing and rate limits will differ based on the model and provider you're using through OpenRouter
- Changing the base URL from
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.