The Opik Python SDK is a key component of our platform, allowing developers to integrate Opik into their Python applications seamlessly. The SDK source code is located in the sdks/python directory of the main comet-ml/opik repository.
Before you start, please review our general Contribution Overview and the Contributor License Agreement (CLA).
To develop and test Python SDK features, you’ll need a local Opik instance running:
Note: The --port-mapping flag exposes all service ports (including MySQL on 3306, ClickHouse on 8123, Redis on 6379) which is useful for debugging. The Python SDK routes traffic through the API gateway (nginx) in the frontend service.
Your local Opik server will be accessible at http://localhost:5173.
Scripts directory (e.g., C:\Users\<name>\AppData\Local\Programs\Python<version>\Scripts\) is in your system’s PATH for the opik CLI command to work after installation. Restart your terminal after adding it.Navigate to the sdks/python directory (or use the path from your virtual environment setup) and install the SDK in editable mode:
Familiarize yourself with the coding guidelines for our Python SDK. This will cover style, conventions, and other important aspects.
Make your desired code changes, additions, or bug fixes within the sdks/python directory.
Testing is crucial. For most SDK contributions, you should run the unit and the end-to-end (e2e) tests:
If you’re making changes to specific integrations (e.g., OpenAI, Anthropic):
pip install -r tests/integrations/openai/requirements.txt (example for OpenAI).python3 -m pytest tests/integrations/openai/ (example for OpenAI).If your changes impact public-facing methods, parameters, or docstrings, please also update the documentation. Refer to the Documentation Contribution Guide for how to update the Python SDK Reference Documentation (Sphinx).