Async Python client for the nicodAImus API.
pip install python-nicodaimusimport aiohttp
from nicodaimus import NicodaimusClient
async with aiohttp.ClientSession() as session:
client = NicodaimusClient(
api_key="sk-your-api-key",
session=session,
)
# Validate your API key
await client.validate_connection()
# Non-streaming chat completion
response = await client.chat_completion(
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Streaming chat completion
async for chunk in client.chat_completion_stream(
messages=[{"role": "user", "content": "Tell me a story"}],
):
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")This library powers the nicodAImus Home Assistant integration.
Apache License 2.0