Skip to main content

Veqen for LangChain and LangGraph

Record model usage and estimated AI cost by customer, feature and project. This package exposes the callback maintained in the Veqen SDK; it does not wrap or alter your model's response.

pip install langchain-veqen langchain-openai
import veqen
from langchain_openai import ChatOpenAI
from langchain_veqen import VeqenCallbackHandler

# No Veqen account needed for local JSONL recording.
veqen.init(ledger_file="ai-costs.jsonl")
model = ChatOpenAI(model="gpt-4o-mini", stream_usage=True)
answer = model.invoke(
    "Explain the difference between input and output tokens.",
    config={"callbacks": [VeqenCallbackHandler(customer="demo", feature="assistant")]},
)
veqen.flush()

Set OPENAI_API_KEY for this example. To send usage to your organization's ledger, set VEQEN_API_KEY to an ingest-only key from Veqen before starting the process. Keep credentials on the server.

Attach the handler to a LangGraph invocation's callback configuration to propagate it to model calls in the graph. Use either this handler or a wrapped provider client for each call, to avoid recording twice.

The handler reads standard AIMessage.usage_metadata and model/provider metadata. Chat integrations must expose that information, including streaming usage when streaming. It separates cache reads and writes from uncached input tokens. Calls without usage metadata or a model identifier are not recorded; it does not guess their token counts. This callback supports token-based chat usage, not every provider-specific media billing field.

Only usage and allocation metadata enter the ledger; prompt and response text are not recorded. Cost uses the SDK's versioned price book and is an estimate until reconciled against the provider bill. Local budgets and cached cloud budget decisions are checked before model execution. See budget behavior and limits.

Integration documentation · Price book · Report a problem

Metadata

Release files for langchain-veqen 1.0.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 langchain-veqen 1.0.0
File Size Uploaded Provenance
langchain_veqen-1.0.0.tar.gz 4.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-veqen 1.0.0
File Interpreter ABI Platform
langchain_veqen-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / langchain_veqen-1.0.0.tar.gz

Download URL langchain_veqen-1.0.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
16f6c84b39b5e84a6f7f18d9f9e9716d2795f102053a72304277a2036661b0f4
BLAKE2b-256 checksum
How to use checksums
4c8847b47bee0a9c4e9269d58f7fd0505bcb9bc81c4a69531eeb24851ff8fab1
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 Oct 23, 2026.

Transparency log

Release files / langchain_veqen-1.0.0-py3-none-any.whl

Download URL langchain_veqen-1.0.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c856a0c17a43a96b50e3de4ccad53d6de8353781b53d5aca4ba34aa3de4d15b
BLAKE2b-256 checksum
How to use checksums
135fd651c8a8eaab7e6f5c244fcd1bfd73778e9ac7c6bbffeaa1276cdbecbfe3
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 Oct 23, 2026.

Transparency log

Security for langchain-veqen 1.0.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_veqen-1.0.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 Oct 23, 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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

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