Connect OpenAI to StackSpend
Track OpenAI API costs including GPT-4, GPT-3.5, and other models. Real-time cost data with project-level breakdowns.
StackSpend tracks OpenAI API costs using your Organization ID and API key. Get model-level breakdown (GPT-4, GPT-3.5, embeddings), daily spend visibility, anomaly detection, and forecasting. Setup takes under 5 minutes. Read-only access.
Prerequisites
- An OpenAI account with API access
- Access to OpenAI Platform dashboard
- API key with billing/usage read permissions
Organization ID Required
OpenAI requires the Organization ID to identify which organization's costs to return. This is different from your API key and must be provided separately.
Get Your Organization ID
Your Organization ID identifies which OpenAI organization's costs to track. You'll need this along with your API key.
- 1Go to OpenAI Settings → Organization → General
- 2Find "Organization ID" (starts with
org-) - 3Copy the full Organization ID (e.g.,
org-abc123def456)
Note: If you have multiple organizations, use the one where your API usage occurs. The Organization ID determines which costs are returned.
Create an API Key
Create an API key with billing access. The key must have permissions to read usage and billing data.
- 1Go to OpenAI API Keys
- 2Click Create new secret key
- 3Select "All" permissions (required for billing access)
- 4Optionally name the key (e.g., "StackSpend Cost Tracking")
- 5Click Create secret key
- 6Important: Copy the API key immediately. It starts with
sk-orsk-admin-. You won't be able to see it again.
Warning: API keys with "All" permissions provide full access to your OpenAI account. Store them securely and never share them publicly.
Connect in StackSpend
Enter your API key and Organization ID in StackSpend.
- 1Go to Settings → Providers in your StackSpend dashboard
- 2Click Add Provider
- 3Select OpenAI
- 4Enter your credentials:
- API Key: Paste your API key (starts with
sk-) - Organization ID: Paste your Organization ID (starts with
org-)
- API Key: Paste your API key (starts with
- 5Click Test Connection to verify your credentials
- 6Once the test succeeds, click Connect
After Connecting
Once OpenAI is connected, StackSpend begins syncing historical cost data. OpenAI provides real-time cost data, so you'll see costs immediately.
- Costs sync automatically every 6 hours
- Real-time cost data (no delay like AWS)
- Project-level cost breakdowns
- Model-level usage tracking (GPT-4, GPT-3.5, etc.)
Troubleshooting
"Invalid credentials" Error
- •Verify your API key is correct and starts with
sk- - •Ensure your Organization ID starts with
org- - •Check that you copied both values completely (no extra spaces)
"No cost data found" Message
- •Verify you have actual OpenAI API usage in the selected date range
- •Check that your Organization ID matches the organization where usage occurred
- •Ensure your API key has "All" permissions (required for billing access)
Empty Results Array
If the connection test succeeds but no cost data appears:
- •The
OpenAI-Organizationheader must be set (StackSpend does this automatically) - •Verify your Organization ID is correct - wrong ID returns empty results