Skip to main content

Basic Initialization

Initialize the SDK with your API key:
from valmi_value import ValueClient

value = ValueClient(api_key="sk_live_abc123xyz")

Configuration Options

Configure the client with additional options:
value = ValueClient(
    api_key="sk_live_abc123xyz",
    api_url="https://api.valmi.io",  # Optional: custom API URL
    timeout=30,  # Request timeout in seconds
    max_retries=3,  # Number of retry attempts
    buffer_size=100,  # Local buffer size for events
    flush_interval=5,  # Seconds between automatic flushes
)

Environment Variables

Use environment variables for configuration:
export VALMI_API_KEY="sk_live_abc123xyz"
export VALMI_API_URL="https://api.valmi.io"
Then initialize without explicit API key:
from valmi_value import ValueClient

value = ValueClient()  # Reads VALMI_API_KEY from environment

Async Initialization

For async applications:
from valmi_value import AsyncValueClient

value = AsyncValueClient(api_key="sk_live_abc123xyz")

Context Manager

Use as a context manager for automatic cleanup:
with ValueClient(api_key="sk_live_abc123xyz") as value:
    value.send_action(...)
    # Client automatically flushes and closes

Client Methods

Once initialized, the client provides:
  • send_action() - Send action events
  • send_outcome() - Send outcome events
  • flush() - Manually flush buffered events
  • close() - Close the client and flush remaining events