Skip to main content

Argosvix Python SDK = AI agent observability (cost / latency / tokens / errors) for OpenAI / Anthropic / Gemini / Mistral

Project description

Argosvix Python SDK

AI agent observability (cost / latency / tokens / errors) for OpenAI / Anthropic / Gemini / Mistral. Sync + async + streaming wrap for all 4 providers. Prompt-caching cost/savings is captured automatically.

PyPI version License: MIT

Install

pip install argosvix
# OR include a specific provider SDK as extra
pip install "argosvix[openai]"
pip install "argosvix[anthropic]"
pip install "argosvix[gemini]"
pip install "argosvix[mistral]"
# all 4 at once
pip install "argosvix[all]"

Quickstart

from openai import OpenAI
from argosvix import wrap, ArgosvixConfig

client = wrap(
    OpenAI(),
    ArgosvixConfig(
        api_key="argosvix_live_...",  # get from https://dashboard.argosvix.com/api-keys
        tags={"service": "my-app", "env": "prod"},
    ),
)

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello"}],
)
# The call is automatically recorded (cost / tokens / latency / model) and
# batched to https://ingest.argosvix.com/v1/ingest within 5 seconds.

Visit https://dashboard.argosvix.com after a few seconds to see the call appear.

Configuration

ArgosvixConfig accepts:

Field Default Description
api_key None Argosvix API key. Required for record submission.
endpoint https://ingest.argosvix.com/v1/ingest Ingest endpoint.
tags {} Tags attached to every record (e.g. {"service": "bot"}).
disabled False Disable record submission entirely (e.g. local dev).
flush_interval_ms 5000 Buffer flush interval.
buffer_max_size 100 Max records before auto-flush.
flush_retry_attempts 2 Total retry attempts including the initial try.
provider None Explicit provider override ("openai" / etc). Auto-detected from client class name.
trace_id None OTel-subset trace ID. Attached to all records from this client.
span_id None OTel-subset span ID.
parent_span_id None OTel-subset parent span ID.

Short-lived processes (Lambda / Cron / CLI)

The SDK auto-registers atexit to flush remaining records when the process exits. But for Lambda / Edge Functions / Workers-style short-lived runtimes where atexit may not fire, explicitly flush:

from argosvix import get_recorder

rec = get_recorder(client)
if rec is not None:
    rec.flush_blocking()  # blocks until all buffered records are POSTed

Supported providers (Phase 4)

Provider Sync Async Streaming Notes
OpenAI client.chat.completions.create (sync + AsyncOpenAI). For token/cost on streams, pass stream_options={"include_usage": True} (OpenAI only emits usage then).
Anthropic client.messages.create(stream=True). The client.messages.stream() context-manager helper is not yet recorded (a warning is logged when present).
Google Gemini generate_content + generate_content_stream (sync client.models + async client.aio.models, google-genai).
Mistral client.chat.complete + complete_async. The separate client.chat.stream helper is not yet recorded (a warning is logged when present).

Streaming notes: argosvix wraps the returned stream transparently and records once on completion (or on the error / early-exit path). Usage tokens arrive at stream completion, so a stream you create but never consume is not recorded. OpenAI Responses API support is backlog. Need a provider or helper sooner? File an issue at https://github.com/argosvix/Argosvix/issues.

Multi-provider example

from openai import OpenAI
from anthropic import Anthropic
from google import genai
from mistralai import Mistral
from argosvix import wrap, ArgosvixConfig

cfg = ArgosvixConfig(api_key="argosvix_live_...", tags={"app": "comparison-bot"})
oa = wrap(OpenAI(), cfg)
an = wrap(Anthropic(), cfg)
gm = wrap(genai.Client(), cfg)
ms = wrap(Mistral(api_key="..."), cfg)

# All calls are recorded to the same Argosvix account, distinguishable by provider.
oa.chat.completions.create(model="gpt-5.5", messages=[{"role": "user", "content": "Hi"}])
an.messages.create(model="claude-opus-4", messages=[{"role": "user", "content": "Hi"}], max_tokens=512)
gm.models.generate_content(model="gemini-2.5-flash", contents="Hi")
ms.chat.complete(model="mistral-large-latest", messages=[{"role": "user", "content": "Hi"}])

Trace correlation

Group related LLM calls into a single trace by passing trace_id to wrap():

import uuid

trace_id = uuid.uuid4().hex
client = wrap(
    OpenAI(),
    ArgosvixConfig(api_key="...", trace_id=trace_id),
)
# All calls from this client share trace_id and appear together in the
# dashboard's traces waterfall view.

Privacy

The SDK records metadata only (= tokens, cost, latency, model name, error info, your tags). Prompts and completions are NOT recorded by default. Opt-in plain-text storage (with PII redaction + AES-256 encryption + 7-30 day retention + 1-click delete) is planned for v1.5 — see https://argosvix.com/privacy for details.

Pricing table

PRICING is a snapshot updated quarterly from each provider's official pricing page. Unknown models return 0.0 cost + a warning. To verify a model is known:

from argosvix import calculate_cost

cost = calculate_cost("openai", "gpt-5.5", prompt_tokens=1000, completion_tokens=500)
print(cost)  # 0.0125 USD

Development

# install with dev deps
pip install -e ".[dev]"

# run tests
pytest

# lint
ruff check argosvix tests

License

MIT © Yuto Makihara (Argosvix). See LICENSE.

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

argosvix-0.4.1a0.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

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

argosvix-0.4.1a0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file argosvix-0.4.1a0.tar.gz.

File metadata

  • Download URL: argosvix-0.4.1a0.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for argosvix-0.4.1a0.tar.gz
Algorithm Hash digest
SHA256 e9a83fe13eb5e83cc41ef36c6065b684c940183fc91c03611e2eba5801d39563
MD5 5983506a0aad89059b196a9848db9902
BLAKE2b-256 4fd5317d62bd110b9ad7281862c007b2a5d18318ec1989b38af196be592ed9b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for argosvix-0.4.1a0.tar.gz:

Publisher: publish-python.yml on argosvix/Argosvix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file argosvix-0.4.1a0-py3-none-any.whl.

File metadata

  • Download URL: argosvix-0.4.1a0-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for argosvix-0.4.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 4461958ebc65a39f7653ac303cd43820cbe6a1fe7e0972821b929f52fc7788bf
MD5 935b0a3002370c9473930dd04ba9eaeb
BLAKE2b-256 b59ddf559d466fa94315fccb1dc83a3b89c797ba64b6fe333cf693899c46752e

See more details on using hashes here.

Provenance

The following attestation bundles were made for argosvix-0.4.1a0-py3-none-any.whl:

Publisher: publish-python.yml on argosvix/Argosvix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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