Skip to main content

Value Python SDK

PyPI version CI Python Versions License: MIT

Python SDK to track AI agents with Value actions and auto-instrument LLM calls (Gemini, LangChain).

Features

  • Value Actions: Track agent behavior using action_context with user_id and anonymous_id, send custom actions via ctx.send()
  • Auto-Instrumentation: Automatically capture LLM calls from Gemini and LangChain with zero code changes
  • OpenTelemetry-Based: Built on OpenTelemetry for standardized, vendor-neutral observability

Installation

Basic Installation

Install the core SDK without auto-instrumentation dependencies:

pip install value-python

With Google GenAI Auto-Instrumentation

Install with Google Generative AI (Gemini) auto-instrumentation support:

pip install value-python[genai]

With LangChain Auto-Instrumentation

Install with LangChain auto-instrumentation support:

pip install value-python[langchain]

With All Auto-Instrumentation Libraries

Install with all supported auto-instrumentation libraries:

pip install value-python[all]

Multiple Extras

You can also install multiple extras:

pip install value-python[genai,langchain]

Supported Platforms

  • Python: 3.9, 3.10, 3.11, 3.12, 3.13
  • Operating Systems: Linux, macOS, Windows

Quick Start

Basic Usage

import asyncio
from value import initialize_async

async def main():
    # agent_secret is required
    client = await initialize_async(agent_secret="your-agent-secret")

    async def process_data(data: str) -> str:
        print(f"Processing data: {data}")
        await asyncio.sleep(0.5)
        result = data.upper()

        with client.action_context(user_id="user123", anonymous_id="anon456") as ctx:
            ctx.send(
                action_name="transform_data",
                **{"value.action.description": f"Transformed data from {len(data)} to {len(result)} characters"}
            )
        return result

    result = await process_data("hello async world")
    print(f"Result: {result}")

asyncio.run(main())

Synchronous Usage

from value import initialize_sync

# agent_secret is required
client = initialize_sync(agent_secret="your-agent-secret")

with client.action_context(user_id="user123", anonymous_id="anon456") as ctx:
    # Your code here
    ctx.send(action_name="my_action", **{"custom.attribute": "value"})

Auto-Instrumentation

Enable automatic tracing for supported AI libraries:

from value import initialize_sync, auto_instrument

# Initialize the client with agent_secret
client = initialize_sync(agent_secret="your-agent-secret")

# Auto-instrument specific libraries
auto_instrument(["gemini", "langchain"])

# Or auto-instrument all available libraries
auto_instrument()

Google GenAI Example

from value import initialize_sync, auto_instrument
from google import genai

# Initialize Value client with agent_secret and auto-instrument
client = initialize_sync(agent_secret="your-agent-secret")
auto_instrument(["gemini"])

# Use Gemini as usual - traces are automatically captured
gemini_client = genai.Client(api_key="your-api-key")
response = gemini_client.models.generate_content(
    model="gemini-2.5-flash",
    contents=["Write a poem about tracing"]
)

print(response.text)

Configuration

The agent_secret is passed directly to initialize_sync() or initialize_async(). Additional configuration can be set using environment variables:

Variable Description Default
VALUE_OTEL_ENDPOINT OpenTelemetry collector endpoint http://localhost:4317
VALUE_BACKEND_URL Value Control Plane backend URL Required
VALUE_SERVICE_NAME Service name for OpenTelemetry resource value-control-agent
VALUE_CONSOLE_EXPORT Enable console span exporter for debugging false

Supported Auto-Instrumentation Libraries

Library Extra Instrumentor
Google Generative AI (Gemini) genai opentelemetry-instrumentation-google-generativeai
LangChain langchain opentelemetry-instrumentation-langchain

API Reference

Core Functions

  • initialize_sync(agent_secret) - Initialize a synchronous Value client
  • initialize_async(agent_secret) - Initialize an asynchronous Value client
  • auto_instrument(libraries=None) - Enable auto-instrumentation for specified libraries
  • uninstrument(libraries=None) - Disable auto-instrumentation
  • get_supported_libraries() - Get list of supported library names
  • is_library_available(library) - Check if a library's instrumentation is installed

Client Methods

  • action_context(user_id=None, anonymous_id=None) - Create a context for sending actions
  • ctx.send(action_name, **attributes) - Send an action with custom attributes

Development

Setup

# Clone the repository
git clone https://github.com/valmi-io/value-python.git
cd value-python

# Install dependencies
poetry install

# Install with all extras for development
poetry install --extras all

Running Tests

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=value --cov-report=html

# Run specific test file
poetry run pytest tests/test_client.py

Code Quality

# Format code
poetry run black src/ tests/

# Lint code
poetry run ruff check src/ tests/

# Type check
poetry run mypy src/

Publishing

The package is automatically published to PyPI when a new release is created on GitHub.

Manual Publishing

# Build the package
poetry build

# Publish to TestPyPI (for testing)
poetry publish -r testpypi

# Publish to PyPI
poetry publish

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Links

Metadata

Release files for value-python 0.1.6

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

Source distribution (sdist)

Source distribution for value-python 0.1.6
File Size Uploaded Provenance
value_python-0.1.6.tar.gz 12.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for value-python 0.1.6
File Interpreter ABI Platform
value_python-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 24.7 kB

Release files / value_python-0.1.6.tar.gz

Download URL value_python-0.1.6.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
566925c7e54d4e7e8622a906683462b3bf62f48d6852e63e2c0c712b87b85222
BLAKE2b-256 checksum
How to use checksums
3d6fdf06f91f6c6112b3d8904b1afbbe236b47103c8410b2879d82d52805ff01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 15, 2025.

Transparency log

Release files / value_python-0.1.6-py3-none-any.whl

Download URL value_python-0.1.6-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96b86ca5e03f1e297f64f56475b7810ac26b67ccc8e41b58e99749718d101976
BLAKE2b-256 checksum
How to use checksums
a419a1137d29cc529dd1deeda840176073dfdd8a8bcd3753a722d77e41f78500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 15, 2025.

Transparency log

Security for value-python 0.1.6

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 value_python-0.1.6.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 Dec 15, 2025.

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.

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