This guide explains how to integrate Opik with OpenRouter using the OpenAI SDK. OpenRouter provides a unified API for accessing hundreds of AI models through a single OpenAI-compatible interface.
First, ensure you have both opik and openai packages installed:
You’ll also need an OpenRouter API key which you can get from OpenRouter.
OpenRouter provides access to a wide variety of models, including many open source models from different providers.
You can find the complete list of available models in the OpenRouter documentation.
OpenRouter supports the following methods:
client.chat.completions.create(): Works with all modelsclient.beta.chat.completions.parse(): Only compatible with OpenAI modelsFor detailed information about available methods, parameters, and best practices, refer to the OpenRouter API documentation.