Observability for Qianfan with Opik
Baidu Qianfan provides OpenAI-compatible API endpoints for hosted model access. This guide shows how to use the OpenAI SDK with Opik to trace and evaluate Qianfan calls.
Getting started
First, ensure you have both opik and openai packages installed:
You will need a Qianfan API key and an OpenAI-compatible base URL. The Qianfan OpenAI-compatible base URL is:
https://api.baiduqianfan.ai/v1
Refer to the Qianfan documentation for the latest setup steps and model list.
Tracking Qianfan API calls
Advanced Usage
Using with @track decorator
You can combine the tracked client with Opik’s @track decorator for
end-to-end tracing:
Troubleshooting
Common Issues
- Authentication Errors: Confirm your API key is valid and has access to Qianfan
- Model Not Found: Verify the model name matches one available in Qianfan
- Base URL Issues: Ensure you are using the OpenAI-compatible endpoint from Qianfan
Getting Help
- Review the Qianfan documentation
- Check Opik tracing docs for setup details: /tracing/advanced/sdk_configuration
Next Steps
Once you have Qianfan integrated with Opik, you can:
For more information about OpenAI-compatible APIs, see the OpenAI integration guide.