Skip to main content

Python client for VAC (Verifiable Agentic Credential) Protocol

Project description

VAC Python Client

Simple Python client for the VAC (Verifiable Agentic Credential) Protocol.

Installation

# Copy vac_client.py to your project, or:
pip install httpx  # Recommended for proper multi-header support

Quick Start

from vac_client import VACClient

# Create client
vac = VACClient(
    sidecar_url="http://localhost:3000",
    root_biscuit="<your-biscuit-token>"
)

# Make requests - receipts auto-accumulate
response = vac.get("/search", params={"q": "flights"})
print(f"Search: {response.status_code}")

response = vac.post("/charge", json={"amount": 100, "currency": "usd"})
print(f"Charge: {response.status_code}")

# Start new workflow (clears receipts, new correlation ID)
vac.clear_receipts()

Features

  • Automatic receipt accumulation
  • Correlation ID management
  • Multiple X-VAC-Receipt header support (with httpx)
  • Error classification (policy violation, expired, etc.)

Error Handling

from vac_client import VACClient, VACError

vac = VACClient(root_biscuit="...")

try:
    response = vac.post("/charge", json={"amount": 100})
    response.raise_for_status()
except VACError as e:
    if e.is_missing_receipt:
        print("Need to complete prior steps first")
    elif e.is_expired:
        print("Receipt expired - restart workflow")
    elif e.is_policy_violation:
        print(f"Policy denied: {e.message}")

Multi-Step Workflows

import uuid
from vac_client import VACClient

# All requests in a workflow share a correlation ID
vac = VACClient(
    root_biscuit="...",
    correlation_id=str(uuid.uuid4())  # Or let it auto-generate
)

# Step 1: Search
vac.get("/search", params={"q": "flights to NYC"})

# Step 2: Select (policy may require search first)
vac.post("/select", json={"flight_id": "AA123"})

# Step 3: Charge (policy may require search + select)
vac.post("/charge", json={"amount": 35000})

# Receipts are automatically included in each request
print(f"Receipts collected: {len(vac.receipts)}")

Requirements

  • Python 3.7+
  • httpx (recommended) or requests

Observability: For OpenTelemetry tracing of VAC requests, install with pip install vac-client[opentelemetry] and use opentelemetry-instrumentation-httpx, or see docs/OBSERVABILITY.md in the repo.

Multi-step workflows (search → select → charge): The sidecar expects multiple X-VAC-Receipt headers, one per prior step. The requests library cannot send multiple headers with the same name, so multi-step workflows will fail with requests. Use httpx for any flow that accumulates more than one receipt.

License

MIT

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

vac_client-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

vac_client-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file vac_client-0.1.0.tar.gz.

File metadata

  • Download URL: vac_client-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for vac_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8daa292c51e947bbd0ac2b1d4c56bca73bcd4a6986e86e574a6bfd48dd14cc7a
MD5 51ec079aa2adedd12f93e8d7bc7615e0
BLAKE2b-256 0ee34dee95e0f6c14bfd3932ff829912c2acfefe26dd775126fe9947741179c3

See more details on using hashes here.

File details

Details for the file vac_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vac_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for vac_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e774cb6334ca2cc21f02fa110d5bb64903b40b2bca7ed8f3919fb41ea95ad311
MD5 35edec20e0b292650e060c5d9192c7b2
BLAKE2b-256 9c0c17209eea039e3d91ca0605e546607788e0be3224dcccc11f6d4d22f435ed

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