Skip to main content

Track AI API costs per client, project, and feature

Project description

Pradvion Python SDK

Track AI API costs per client, project, and feature. Know exactly what to bill each client.

Installation

pip install pradvion

Quick Start

import openai import pradvion

pradvion.init(api_key="nx_live_YOUR_KEY") client = pradvion.wrap(openai.OpenAI())

response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello"}] )

Cost automatically tracked in dashboard

Context Manager

with pradvion.context( feature="resume-summarizer", customer_id="samsung-001", environment="production" ): response = client.chat.completions.create(...)

Middleware Pattern (FastAPI)

@app.middleware("http") async def pradvion_middleware(request, call_next): user = get_current_user(request) pradvion.set_context( customer_id=user.company_id, environment="production" ) response = await call_next(request) pradvion.clear_context() return response

Async Support

async_client = pradvion.wrap(openai.AsyncOpenAI()) response = await async_client.chat.completions.create(...)

Streaming

stream = client.chat.completions.create( model="gpt-4o", messages=[...], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content, end="")

Usage captured automatically from last chunk

Agent / RAG Usage

with pradvion.context(feature="research-agent", customer_id="samsung"): # All sub-calls tracked under same context search = client.chat.completions.create(...) analyze = client.chat.completions.create(...) report = client.chat.completions.create(...)

Support

hello@pradvion.com | https://pradvion.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pradvion-0.2.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pradvion-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file pradvion-0.2.0.tar.gz.

File metadata

  • Download URL: pradvion-0.2.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pradvion-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a7d32a61f000b96e64bf935170647f821d20f31bd61b4ebbf83a388f8b9f389f
MD5 3e50271e66d8e44f29f3628fb6a507da
BLAKE2b-256 b8dc51c691160d35affbdbc7557b95c03e2c43be8265e504ed19e59c54a8ec62

See more details on using hashes here.

File details

Details for the file pradvion-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pradvion-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pradvion-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d01fbacf45f6b0f31ddd871bb9c43a3042529ed4669855d3c53a589a062b2476
MD5 5be23c421b65674e68adadcb79822835
BLAKE2b-256 4adf1f9a52b98a122ad905ddbdc366f648d718a551d863c0a7ea77900cb82375

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page