Skip to main content

pump-openai-radar

OpenAI infrastructure FinOps SDK — part of the Hyperscaler Radar suite.

PyPI Python License: MIT

Scan your OpenAI org for assistants, vector stores, fine-tunes, batch jobs, and token usage. Detect external service relationships in assistant instructions, flag cost anomalies via a findings engine, and export inventory to CSV or a draw.io architecture diagram — all through a clean Python SDK that mirrors the openai-agents Runner API.


Install

pip install pump-openai-radar                   # SDK + CLI + CSV and draw.io export
pip install pump-openai-radar[agents]           # + openai-agents integration
pip install pump-openai-radar[all]              # everything

Requires Python 3.10+.

CSV and draw.io export are part of the base install — no extras needed, same as the rest of the Radar suite. The [csv] and [drawio] extras still resolve (as no-ops) so older pins keep working.


Quick-start

from openai_radar import RadarClient, Runner

# Reads OPENAI_API_KEY from environment
client = RadarClient()

result = Runner.run_sync(client)

print(result.summary())
result.export_csv("./out/")
result.export_drawio("./out/openai_arch.drawio")

With admin key (org-wide visibility)

client = RadarClient(
    api_key="sk-proj-...",
    admin_key="sk-admin-...",  # unlocks cross-project usage data
)
result = Runner.run_sync(client, config)

Scoped to a project

from openai_radar import RadarClient, Runner, RunConfig

client = RadarClient()
config = RunConfig(project_id="proj_xxx", usage_lookback_days=7)
result = Runner.run_sync(client, config)

CLI

# Full scan — findings table to stdout
pump-openai-radar run

# CSVs + draw.io diagram
pump-openai-radar run --csv-dir ./out --drawio-file arch.drawio

# JSON instead of a table
pump-openai-radar run --output json --out-file scan.json

# Admin key for org-wide usage data
pump-openai-radar run --admin-key sk-admin-... --csv-dir ./out

# Findings only
pump-openai-radar findings

# Scope to a project, 7-day lookback
pump-openai-radar run --project proj_xxx --lookback 7

# Log in to Pump, then push the org cost report (admin key required)
pump-openai-radar login
pump-openai-radar run --admin-key sk-admin-... --upload

# Check or forget the stored Pump token
pump-openai-radar status
pump-openai-radar logout

# Print the version
pump-openai-radar version

Flags follow the Radar suite convention: --output/-o selects table or json, --out-file writes the JSON payload, --csv-dir writes per-resource CSVs. --upload writes report.csv (costs) and usage.csv (token usage) and pushes them with the token from pump-openai-radar login. Costs upload as role billing; usage uploads as role inventory. --upload-token does the same with a one-shot token and overrides the stored login. --report-file chooses the cost CSV path; with --csv-dir and no --report-file it is {csv-dir}/report.csv. usage.csv is written next to it.


Pump onboarding

The token is exchanged for a presigned S3 URL, and only the cost and usage CSVs leave the machine.

  1. Log in. This runs the browser OAuth flow and stores an upload token locally:

    pump-openai-radar login
    
  2. Scan and upload with an OpenAI admin key:

    pump-openai-radar run --admin-key sk-admin-... --upload
    

    This scans the org, pulls daily costs from /organization/costs, writes report.csv and usage.csv, and uploads them with the stored token. Costs are role billing; usage is role inventory. --csv-dir and --drawio-file still work on the same command. Pass --report-file to choose where the cost CSV is written.

  3. Pump detects the upload and runs its analysis.

pump-openai-radar status shows whether a token is stored (not the token itself). pump-openai-radar logout deletes it. A one-shot token still works without logging in:

pump-openai-radar run --admin-key sk-admin-... --upload-token <TOKEN>

report.csv columns:

Column Meaning
Date UTC day (YYYY-MM-DD)
ProjectID OpenAI project, or -
LineItem Cost line item (model and token category)
Amount Non-zero cost, 6 decimal places
Currency e.g. USD

Zero-cost buckets are omitted. The token carries no company id — Pump binds the company and the S3 key server-side. Login stores the API origin it used, and run --upload sends the report there. Override it with --api-base or PUMP_API_BASE (default https://api.pump.co):

pump-openai-radar run --admin-key sk-admin-... --upload-token <TOKEN> --api-base http://localhost:8001
# or
PUMP_API_BASE=http://localhost:8001 pump-openai-radar run --admin-key sk-admin-... --upload-token <TOKEN>

openai_radar/upload.py posts {api_base}/api/v1/estimate/radar/urls once per file, with {"token", "role", "provider": "openai"}. Costs use role billing and usage uses role inventory. Each CSV is then PUT as Content-Type: text/csv (the presigned URL signs that content type).


openai-agents integration

pip install pump-openai-radar[agents]
from openai_radar.agents import build_radar_agent
from agents import Runner

agent = build_radar_agent()
result = Runner.run_sync(agent, "Scan my org and flag any cost anomalies")
print(result.final_output)

Or compose individual Radar tools into your own agent:

from agents import Agent
from openai_radar.agents.tools import scan_assistants, run_findings, export_drawio

agent = Agent(
    name="My FinOps Agent",
    instructions="...",
    tools=[scan_assistants, run_findings, export_drawio],
)

Findings engine

Rule ID Severity Condition
ASST_001 LOW Assistant has zero tools
ASST_002 INFO Code Interpreter enabled (file storage costs)
VS_001 MEDIUM Vector store > 5 GB
VS_002 HIGH Vector store expires within 7 days
FT_001 MEDIUM Fine-tune job in failed state
BATCH_001 HIGH Batch job failure rate > 10%
USAGE_001 MEDIUM Model consumes > 10M tokens in lookback window

Service relationship detection

AssistantScanner inspects each assistant's instructions field for external service signals and emits ServiceRelationship objects (visualized as edges in the draw.io diagram):

Kind Signals
AWS aws, s3, ec2, lambda, dynamodb, sqs
GCP gcp, bigquery, gcs, google cloud
AZURE azure, blob.core.windows, cosmosdb
DATABASE postgres, mysql, mongo, redis, neon
SLACK slack
EMAIL sendgrid, mailgun, smtp
WEBHOOK webhook, http://

SDK structure

src/openai_radar/
├── client.py            # RadarClient (auth, project vs admin key)
├── runner.py            # Runner, RunConfig, RunResult
├── findings.py          # FindingEngine, Finding, Severity
├── models/base.py       # Pydantic v2 models for all resource types
├── scanners/            # One scanner per resource type, plus the cost report
├── exporters/           # CSV + draw.io exporters
├── pump_login.py        # `login` / `logout` / `status` (OAuth + PKCE)
├── upload.py            # Pump presigned-URL upload (billing + inventory)
├── agents/              # openai-agents tools + build_radar_agent()
└── cli.py               # pump-openai-radar CLI

Development

Python 3.10 or newer. From a checkout:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[all]"

With uv:

uv venv
source .venv/bin/activate
uv pip install -e ".[all]"

The package lives in src/openai_radar, including cli.py and pump_login.py.

From this checkout:

./pump-openai-radar --help
./pump-openai-radar login
./pump-openai-radar status
./pump-openai-radar logout
./pump-openai-radar run --upload
./pump-openai-radar version

login opens a browser for the Pump OAuth flow and writes the token to $XDG_CONFIG_HOME/pump-openai-radar/credentials.json, or ~/.config/pump-openai-radar/credentials.json when XDG_CONFIG_HOME is unset. OPENAI_RADAR_CONFIG_DIR overrides that directory. PUMP_API_BASE and PUMP_APP_BASE override the Pump origins, as do --api-base and --app-base. run --upload sends report.csv with the stored token. Scans still read OPENAI_API_KEY and, for org-wide usage, OPENAI_ADMIN_KEY.

Login tests talk to a local fake Pump:

python -m unittest tests.test_pump_login

Part of the Hyperscaler Radar suite

aws-radar · gcp-radar · azure-radar · oci-radar · pump-openai-radar ·claude-radar · gemini-radar · datadog-radar

Metadata

Release files for pump-openai-radar 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pump-openai-radar 0.0.3
File Size Uploaded
pump_openai_radar-0.0.3.tar.gz 174.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pump-openai-radar 0.0.3
File Interpreter ABI Platform
pump_openai_radar-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 218.8 kB

Release files / pump_openai_radar-0.0.3.tar.gz

Download URL pump_openai_radar-0.0.3.tar.gz
Size 174.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ca1495550ecaa948bca198015dfc05bc6529e2811a72a03ecab93c67c102b2db
BLAKE2b-256 checksum
How to use checksums
79972746bbb6c268f3bf2eaff497fe9a0045a70d200cc58523d1814101a28bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / pump_openai_radar-0.0.3-py3-none-any.whl

Download URL pump_openai_radar-0.0.3-py3-none-any.whl
Size 44.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a21c61a8fd5ee04c59120127825bc07b1329363e116a4bf081f875dbdd544c6
BLAKE2b-256 checksum
How to use checksums
63c2c7a5f18eaa23c6f594ea1b4e8f22823e8ee4ccd211ded35a83b02e750c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

0.0.5

2 release files

0.0.4

2 release files

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page