> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valmi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialization

> Initializing the Valmi Value SDK client

## Basic Initialization

Initialize the SDK with your API key:

```python theme={null}
from valmi_value import ValueClient

value = ValueClient(api_key="sk_live_abc123xyz")
```

## Configuration Options

Configure the client with additional options:

```python theme={null}
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:

```bash theme={null}
export VALMI_API_KEY="sk_live_abc123xyz"
export VALMI_API_URL="https://api.valmi.io"
```

Then initialize without explicit API key:

```python theme={null}
from valmi_value import ValueClient

value = ValueClient()  # Reads VALMI_API_KEY from environment
```

## Async Initialization

For async applications:

```python theme={null}
from valmi_value import AsyncValueClient

value = AsyncValueClient(api_key="sk_live_abc123xyz")
```

## Context Manager

Use as a context manager for automatic cleanup:

```python theme={null}
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
