# OpenAI Billing — how to use (mcp.ai)

OpenAI organization usage and cost reporting through an admin API key connected by the user.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_openai_billing?ms=1781685900000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `openai_billing_cost`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/openai_billing`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/openai_billing/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/openai_billing/cost` — Get normalized OpenAI organization costs for a date range. Returns compact totals and daily costs.
  - body: { days_back?: integer, start_time?: integer, end_time?: integer, bucket_width?: string, group_by?: string, limit?: integer, account?: string }
- `POST https://api.mcp.ai/api/openai_billing/list/accounts` — List OpenAI Billing admin API connections linked to this install.
  - body: { account?: string }
- `POST https://api.mcp.ai/api/openai_billing/usage` — Get normalized OpenAI organization usage for completions, embeddings, images, audio, vector stores, or code interpreter sessions.
  - body: { kind?: string, days_back?: integer, start_time?: integer, end_time?: integer, bucket_width?: string, group_by?: string, limit?: integer, account?: string }

## Example prompts
- "Show OpenAI costs for the last 30 days"
- "Break down OpenAI completion usage by day"
- "Compare OpenAI usage across embeddings and completions"

## More
- Page: https://mcp.ai/openai_billing
- Agent spec (llms.txt): https://mcp.ai/openai_billing/llms.txt
- Postman collection: https://mcp.ai/openai_billing/postman.json
