Python SDK for Latch LLM Control Plane - Intelligent routing & cost optimization
Project description
Latch AI
Python SDK for the Latch LLM Control Plane - Intelligent routing & cost optimization.
Installation
pip install latch-ai
Quick Start
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
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:
decision = client.decide(
messages=[{"role": "user", "content": "..."}],
task="summarization",
)
print(f"Recommended model: {decision.model}")
print(f"Estimated cost: ${decision.estimated_cost}")
Configuration
client = Latch(
api_key="lgk_xxx",
base_url="https://api.latch.dev",
timeout=30.0,
mode="enforce",
)
Modes
observe: Log decisions, don't enforcesuggest: Return recommendationsenforce: Apply decisions, block if budget exceeded
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
latch_ai-0.1.0.tar.gz
(245.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
latch_ai-0.1.0-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file latch_ai-0.1.0.tar.gz.
File metadata
- Download URL: latch_ai-0.1.0.tar.gz
- Upload date:
- Size: 245.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0493c8b6dbe9cdae0698eea47323b6b0417774e67ca4aab33ecf84647add723
|
|
| MD5 |
ce741942b128b1aeeabf1e2cd632130a
|
|
| BLAKE2b-256 |
057bb3aedfcd1531d6ee8590362cbbdc3683bfb61e6fa131a5bb24e3d1058d2f
|
File details
Details for the file latch_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: latch_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b75f66863e7c2693ffff4f7b1ca9273e0adc307adbfe243344f4d0ebd5d0a926
|
|
| MD5 |
cee8e50d72a27dcf03487cbbb7145457
|
|
| BLAKE2b-256 |
26fd67211cb90c633aef2fdce7ed423fbcde17fc08d6d0a30568b751cfabbb9d
|