Skip to content
AISpendbook

Start here

Quickstart

Install the Python SDK, set two environment variables and attribute your first AI calls.

Install the Python SDK, set two environment variables, and wrap AI calls with track() to attribute them to a customer and feature. Create the ingestion key in Integrations, under SDK / HTTP ingestion. The SDK installs from GitHub.

quickstart
pip install git+https://github.com/AISpendbook/aispendbook-python
export SPENDBOOK_API_KEY=afk_your_key        # ingestion key, shown once
export SPENDBOOK_ENDPOINT=https://www.aispendbook.com   # AI Spendbook API base URL (your own URL if self-hosted)
# in your app
from spendbook import track
  • SPENDBOOK_API_KEY: the ingestion key. It starts with afk_ and is shown once.
  • SPENDBOOK_ENDPOINT: the AI Spendbook API base URL, https://www.aispendbook.com on the hosted service. Events go to https://www.aispendbook.com/api/v1/ingest/batch.
  • Billing data comes from the provider connectors (Anthropic, OpenAI, Google Gemini). The SDK adds who and what each request was for.
  • No provider connector has been run against a live account yet. Check the first sync against the provider's own console.

Next: the full Python SDK guide, the Node.js SDK, framework traces, or the ingestion API for other languages.