Overview
Track costs and monitor usage for OpenAI’s API (GPT-4, GPT-3.5, o1) by routing your requests through LLM Ops. This guide shows you how to integrate using Python, JavaScript, or cURL.Security Guarantee: LLM Ops does not store your API keys, request prompts, or response content in the analytics database—only metadata needed for cost analytics. The proxy must forward request bodies to OpenAI to complete the call; optional operational logging may exist in your deployment environment.
Quick Start
The OpenAI official SDKs expectbase_url (or baseURL) to include the /v1 path segment (e.g. https://api.openai.com/v1). Point that at the LLM Ops API host:
- Original:
https://api.openai.com/v1 - LLM Ops (SDK
base_url/baseURL):https://api.llm-ops.cloudidr.com/v1 - cURL: use the full URL
https://api.llm-ops.cloudidr.com/v1/chat/completions
/v1; OpenAI’s SDK uses a base URL with /v1.
API Keys
You’ll need two credentials:- OpenAI API Key - Your API key from platform.openai.com
- Cloudidr Key - Your tracking token from the LLM Ops dashboard (tokens are typically prefixed with
trk_)
Integration Examples
- Python
- JavaScript
- cURL
Cost Tracking Headers
Add these headers to organize your costs by department, team, or agent:Supported Models
All OpenAI models are supported. See the Supported Models page for the complete list of available models and pricing.What Gets Tracked
LLM Ops automatically captures: ✅ Token usage - Prompt, completion, and total tokens✅ Cost - Real-time cost calculation
✅ Latency - Request duration (TTFT, total time)
✅ Model - Which OpenAI model was used
✅ Metadata - Department, team, agent
✅ Errors - Failed requests and error types
✅ Function calls - Tool/function usage tracking
View Your Data
After making requests, view your costs in the LLM Ops Dashboard:- Agent Explorer - See costs by agent/application
- Department Breakdown - Compare department spending
- Team Analysis - Track team-level costs
- Model Comparison - Compare costs across models
- Time Series - Track spending over time
- Cost Optimization - Get recommendations for cheaper models
Migration from Direct API
Switching from direct OpenAI API to LLM Ops is a two-line change:Cost Optimization Tips
Compare Model Costs in Dashboard
Compare Model Costs in Dashboard
Use the LLM Ops dashboard to identify which agents can switch to cheaper models:
- Track cost per request by model
- Compare quality vs. cost trade-offs
- Identify high-volume, low-complexity tasks
Monitor Function Call Costs
Monitor Function Call Costs
Function calling adds token overhead:
- Track function call frequency per agent
- Identify redundant or unnecessary calls
- Optimize function descriptions to reduce tokens
Enable Prompt Caching
Enable Prompt Caching
OpenAI’s prompt caching can reduce costs for repeated system prompts:
- Track cache hit rates in dashboard
- Identify agents with repeated prompts
- Structure prompts for maximum cache benefit
Troubleshooting
Requests not being tracked
Requests not being tracked
Check these common issues:
- ✅ For OpenAI SDKs, set
base_url/baseURLtohttps://api.llm-ops.cloudidr.com/v1(OpenAI expects the/v1prefix). - ✅ For cURL, call
https://api.llm-ops.cloudidr.com/v1/chat/completions. - ✅ Confirm the header name is
X-Cloudidr-Key(notX-Cloudidr-Token) on every request. - ✅ Check that your OpenAI API key is valid.
Authentication errors
Authentication errors
Two separate keys are needed:
- Your OpenAI API key (for GPT access)
- Your Cloudidr tracking token (for cost tracking)
Cost data not appearing
Cost data not appearing
Wait a few moments:
- Cost data may take 10-30 seconds to appear in dashboard
- Check the correct time range in dashboard filters
- Verify requests are returning 200 OK status
Next Steps
View Dashboard
See your OpenAI API costs in real-time
Supported Models
View all supported OpenAI models
Anthropic Integration
Add cost tracking for Claude models
Set Budgets
Configure spending alerts and limits

