SDK · Python
LatentKit Python SDK
Official-style usage for the Python client: install, synchronous context manager, and an async entrypoint. Samples use syntax highlighting, generous padding, and a horizontal scrollbar for long lines so nothing is clipped by the layout.
Install
Requires a supported Python 3 release (check LatentKit docs for the exact minimum).
pip install latentkitSync usage
Blocking client with a context manager — ideal for scripts and simple workers.
from latentkit import LatentKit
with LatentKit(api_key="YOUR_RAW_KEY") as client:
response = client.chat.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)
print(response.choices[0].message.content)Async usage
Async client for asyncio services. Adjust method names to match the SDK version you pin in production.
import asyncio
from latentkit import AsyncLatentKit
async def main():
async with AsyncLatentKit(api_key="YOUR_RAW_KEY") as client:
response = await client.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].text)
asyncio.run(main())