2-3 min setup

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.

Step 1

Get Your Organization ID

Your Organization ID identifies which OpenAI organization's costs to track. You'll need this along with your API key.

  1. 1Go to OpenAI Settings → Organization → General
  2. 2Find "Organization ID" (starts with org-)
  3. 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.

Step 2

Create an API Key

Create an API key with billing access. The key must have permissions to read usage and billing data.

  1. 1Go to OpenAI API Keys
  2. 2Click Create new secret key
  3. 3Select "All" permissions (required for billing access)
  4. 4Optionally name the key (e.g., "StackSpend Cost Tracking")
  5. 5Click Create secret key
  6. 6Important: Copy the API key immediately. It starts with sk- or sk-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.

Step 3

Connect in StackSpend

Enter your API key and Organization ID in StackSpend.

  1. 1Go to SettingsProviders in your StackSpend dashboard
  2. 2Click Add Provider
  3. 3Select OpenAI
  4. 4Enter your credentials:
    • API Key: Paste your API key (starts with sk-)
    • Organization ID: Paste your Organization ID (starts with org-)
  5. 5Click Test Connection to verify your credentials
  6. 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-Organization header must be set (StackSpend does this automatically)
  • Verify your Organization ID is correct - wrong ID returns empty results

Know where your cloud and AI spend stands — every day, starting today.

Sign up
Connect OpenAI to StackSpend — Step-by-Step Guide