Skip to main content

halvorai-ingest

Signed, attributed payment events for AI agents. HalvorAI records each payment an agent makes, with the agent, the owner it acted for, the instruction it followed and the network proof that came with it. It is never in the payment path: it cannot slow or block a payment.

Developer preview. The SDK works offline today: build, sign and inspect events with your own sink. Sandbox API keys go to early-access teams. Request access.

Install

pip install halvorai-ingest

Try it offline

No account needed. Events are signed with your own Ed25519 key and handed to your sink instead of the API.

import json

from halvorai_ingest import HalvorClient, agent_context, generate_source_key

halvor = HalvorClient(
    source_key=generate_source_key(),  # private JWK; keep it secret
    environment="test",
    sink=lambda envelopes: print(json.dumps(envelopes, indent=2)),
)

with agent_context(
    agent={"id": "agt_travel_12", "name": "Travel booking agent"},
    owner={"id": "own_u_4410", "type": "person", "country": "US"},
    instruction={"id": "task_8890", "text": "Book a return flight to Austin under $500"},
):
    halvor.emit(
        {
            "type": "payment.settled",
            "payment": {
                "payment_id": "pi_3QxAbCdEfGhIjKlM",
                "rail": "stripe",
                "amount": {"value": "41200", "unit": "minor", "currency": "USD"},
                "status": "settled",
                "rail_ref": {"payment_intent": "pi_3QxAbCdEfGhIjKlM"},
            },
            "payee": {"type": "merchant", "name": "Example Airways"},
        }
    )

halvor.flush(timeout=5)

emit returns at once and never raises; a background thread signs and sends events. Instruction text is hashed on your machine and never sent. Anyone with the public half of the key (the JWK without d) can check an envelope with verify_event(envelope["event"], envelope["sig"], public_key).

Send to HalvorAI (early access)

With a sandbox key (hk_test_…), register this machine as a source. init creates an Ed25519 key here, registers its public half, writes HALVOR_API_KEY and HALVOR_SOURCE_KEY to .env.local, sends one test event and prints a dashboard link:

halvorai-ingest init            # or: python -m halvorai_ingest init

It asks for the key unless --api-key or HALVOR_API_KEY is set. Other options: --endpoint, --name, --cwd, --dashboard. The private key never leaves your machine; keep it in your secret manager.

Then load .env.local (or set the same variables) and create the client:

import os

from halvorai_ingest import HalvorClient

halvor = HalvorClient(
    api_key=os.environ["HALVOR_API_KEY"],
    source_key=os.environ["HALVOR_SOURCE_KEY"],  # the private JWK as JSON
)

Delivery

  • Events are sent every flush_interval seconds (default 1), or sooner when a batch of batch_size is full.
  • Network errors, 408, 425, 429 and 5xx are retried with backoff (retry_delays, default 1, 2, 4, 8, 16, 32 s). Permanent errors (400, 401, 403, 404, 405, 409, 410, 415, 422) are not retried; the batch is reported through on_error with the API's serverCode and requestId.
  • Pass spool_dir to keep batches that could not be delivered on disk. The next flush() or process replays them. Rejected batches go to <spool_dir>/dead/. Limits: spool_max_bytes (50 MB) and spool_max_age (7 days), oldest first.
  • stats() returns counts: emitted, accepted, duplicates, rejected, dropped, retries, spooled, replayed, and the dropped_* reasons.

Long-running processes need nothing else: queued events are flushed at exit (up to 2 s). In a short-lived script, a serverless handler or a worker task, flush before you return:

result = halvor.flush(timeout=5)   # {"drained": True} when everything was handled

Or use the client as a context manager, which closes it on exit:

with HalvorClient() as halvor:
    ...

x402

Put the HalvorAI transport under the httpx client your agent pays with. Payment requirements, signed payment payloads and settlement responses become events. Headers are only read; nothing in the payment path changes.

import httpx

from halvorai_ingest.x402 import AsyncHalvorX402Transport, HalvorX402Transport

client = httpx.Client(transport=HalvorX402Transport(halvor))
async_client = httpx.AsyncClient(transport=AsyncHalvorX402Transport(halvor))

To keep a custom transport, pass it as inner: HalvorX402Transport(halvor, inner=my_transport). If you already have a client object, wrap_httpx(client, halvor) and wrap_httpx_async(client, halvor) observe every method except stream().

Each 402 challenge becomes a payment.requested event. The payment that answers it becomes payment.authorized, linked to the challenge with related.previous_event_id, and the settlement becomes payment.settled or payment.failed with the same payment_id. A challenge without a network or token address is reported as invalid_event and not recorded.

Stripe

Pass each verified Stripe webhook event to halvor.stripe(event). PaymentIntents, refunds and disputes are recorded on the stripe rail. Stripe Issuing authorizations and transactions are recorded on the card rail. Any other event type returns None and is ignored. The adapter does not import the Stripe library, and it accepts a plain dict or a stripe.Event.

import stripe

from halvorai_ingest import agent_context
from halvorai_ingest.stripe import tag_issuing_card, tag_payment_intent

# Tag what the agent creates, so its webhooks map back to the agent, owner and instruction.
with agent_context(agent={"id": "agt_travel_12", "name": "Travel agent"}, owner={"id": "own_4410", "type": "business"}):
    card = stripe.issuing.Card.create(**tag_issuing_card({"cardholder": "ich_...", "currency": "usd", "type": "virtual"}))
    intent = stripe.PaymentIntent.create(**tag_payment_intent({"amount": 41200, "currency": "usd"}))

# In your webhook endpoint, after Stripe's own signature check:
event = stripe.Webhook.construct_event(payload, sig_header, endpoint_secret)
halvor.stripe(event)

The tags are metadata.halvor_* keys, taken from agent_context or from keyword overrides (agent_id, agent_name, framework, owner_id, owner_type, instruction_id). Put them on the card for Issuing: card webhooks carry no other agent name. An event without tags is recorded as unattributed. map_stripe_event(event) returns the event without queuing it. The mapping is the same as in the Node.js and Go SDKs.

MPP and MCP adapters are in the Node.js SDK, @halvorai/ingest. Guides for each: docs.halvorai.com.

Develop

uv sync --extra dev
uv run pytest
uv run mypy

Security

Report vulnerabilities privately to hello@halvorai.com.

License

Apache-2.0

Metadata

Release files for halvorai-ingest 0.5.0

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

Source distribution (sdist)

Source distribution for halvorai-ingest 0.5.0
File Size Uploaded Provenance Actions
halvorai_ingest-0.5.0.tar.gz 59.7 kB With provenance Details for halvorai_ingest-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for halvorai-ingest 0.5.0
File Interpreter ABI Platform Actions
halvorai_ingest-0.5.0-py3-none-any.whl Python 3 none any Details for halvorai_ingest-0.5.0-py3-none-any.whl

Total release size: 104.0 kB

Release files / halvorai_ingest-0.5.0.tar.gz

Download URL halvorai_ingest-0.5.0.tar.gz
Size 59.7 kB
Tags Source
SHA-256 checksum
How to use checksums
16600a3eadeca935b8c17d3713e9c5cb4601008956bdf5b7fec52ed2351adee3
BLAKE2b-256 checksum
How to use checksums
e22ad1cd3263ab02c2c9947d73289b0ddfd3dc6406223eadf8876116f80e2c0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / halvorai_ingest-0.5.0-py3-none-any.whl

Download URL halvorai_ingest-0.5.0-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c052d127ba46836f225fadd5967f7809d2a6e0d06b4f27687c7f1743b01dc458
BLAKE2b-256 checksum
How to use checksums
19c3b9db509e50a7eedd72a8de9ecfa4e3ba87246b7be04113966cf617972ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for halvorai-ingest 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for halvorai_ingest-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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