Metadata-Version: 2.4
Name: latentkit
Version: 0.1.1
Summary: Python client for the LatentKit gateway (OpenAI-compatible /v1 HTTP API).
Project-URL: Homepage, https://ai.latentkit.com
Project-URL: Documentation, https://ai.latentkit.com/developers/examples
Project-URL: Repository, https://github.com/latentkit/latentkit
Author: LatentKit
License: MIT
Keywords: ai,gateway,latentkit,llm,openai-compatible,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# LatentKit Python SDK

Official Python client for the canonical LatentKit `/v1` API.

## Install

```bash
pip install latentkit
```

Requires Python 3.10+.

## Quickstart

```python
from latentkit import LatentKit, LatentKitAPIError

client = LatentKit(api_key="YOUR_RAW_KEY")
try:
    response = client.chat.create(
        messages=[{"role": "user", "content": "Say hello from LatentKit."}],
        max_tokens=100,
        response_profile="balanced",
    )
    print(response["content"])
except LatentKitAPIError as exc:
    print(exc.status_code, exc.body)
client.close()
```

## Async

```python
import asyncio

from latentkit import AsyncLatentKit


async def main() -> None:
    async with AsyncLatentKit(api_key="YOUR_RAW_KEY") as client:
        response = await client.completions.create(
            prompt="Write a short product description for LatentKit.",
            system="Respond in one sentence.",
        )
        print(response["content"])


asyncio.run(main())
```

## Timeouts and custom clients

`LatentKit(...)` and `AsyncLatentKit(...)` create `httpx` clients with a default timeout of `120s`.

If you inject your own `http_client`, configure timeouts on that client yourself:

```python
import httpx
from latentkit import LatentKit

http_client = httpx.Client(timeout=30.0)
client = LatentKit(api_key="YOUR_RAW_KEY", http_client=http_client)
```

## Streaming

```python
from latentkit import LatentKit

with LatentKit(api_key="YOUR_RAW_KEY") as client:
    for event in client.chat.stream(
        messages=[{"role": "user", "content": "Count from one to five."}],
    ):
        if event.event == "error":
            raise RuntimeError(event.data)
        if event.is_done:
            break
        print(event.data["delta"], end="")
```

## Response profiles

Pass `response_profile` to ask the assigned policy for a speed/depth tradeoff:

```python
response = client.chat.create(
    messages=[{"role": "user", "content": "Give me the short version."}],
    response_profile="fast",
)
```

Allowed values are `fast`, `balanced`, and `deep`. The assigned policy controls whether request overrides are allowed and which routes are eligible for each profile.

## Agent sessions

```python
from latentkit import LatentKit

with LatentKit(api_key="YOUR_RAW_KEY") as client:
    session = client.agents.sessions.create(
        task="Inspect the repo and explain the auth flow",
        workspace_root="/workspace",
        permission_mode="workspace-write",
    )
    queued = client.agents.sessions.run(session["id"])
    print(queued)
```

See [`docs/latentkit-coder-api.md`](../../docs/latentkit-coder-api.md) for the full agent session request/response model.

## Modalities

```python
with LatentKit(api_key="YOUR_RAW_KEY") as client:
    client.embeddings.create(input=["hello world"], dimensions=256)
    client.image.generate(prompt="A clean product icon", size="1024x1024")
    client.speech.create(input="Hello from LatentKit.", voice="alloy")
    client.transcription.create(audio={"base64": "..."}, language="en")
    client.translation.create(audio={"base64": "..."}, target_language="en")
    client.video.generate(prompt="A short product scene", duration_seconds=4)
```
