semvec/pypi-packages huggingface dataset:
latch-ai 0.1.0
Python SDK for Latch LLM Control Plane - Intelligent routing & cost optimization
License: MIT
Requires Python: >=3.10
Keywords: ai, cost-optimization, llm, routing

# Latch AI

Python SDK for the Latch LLM Control Plane - Intelligent routing & cost optimization.

## Installation

```bash
pip install latch-ai
```

## Quick Start

```python
from latch import Latch

client = Latch(api_key="lgk_your_api_key")

response = client.run(
    messages=[{"role": "user", "content": "Summarize this document..."}],
    task="summarization",
    budget=0.02,
)

print(response.content)
print(f"Cost: ${response.cost}")
print(f"Model: {response.model}")
```

## Async Usage

```python
from latch import AsyncLatch

async with AsyncLatch(api_key="lgk_your_api_key") as client:
    response = await client.run(
        messages=[{"role": "user", "content": "Hello!"}],
        task="chat",
    )
    print(response.content)
```

## Decision Only

Get routing decision without executing:

```python
decision = client.decide(
    messages=[{"role": "user", "content": "..."}],
    task="summarization",
)

print(f"Recommended model: {decision.model}")
print(f"Estimated cost: ${decision.estimated_cost}")
```

## Configuration

```python
client = Latch(
    api_key="lgk_xxx",
    base_url="https://api.latch.dev",
    timeout=30.0,
    mode="enforce",
)
```

### Modes

- `observe`: Log decisions, don't enforce
- `suggest`: Return recommendations
- `enforce`: Apply decisions, block if budget exceeded