Python client for the Nova AI API
Project description
Python SDK
Python client for the Nova AI API.
The package is intentionally small:
- sync methods
- no external dependencies
- typed request and response structures
- simple streaming support for chat completions with a normal
forloop - audio helpers for transcription, translation, and speech generation
Install
pip install datalabrotterdam-nova-sdk
Create A Client
from nova_ai import NovaAIClient
client = NovaAIClient(
api_key="sk_live_..."
)
If you do not pass base_url, the client uses https://api.nova.datalabrotterdam.nl/v1.
Example: Normal Chat
from nova_ai import NovaAIClient
client = NovaAIClient(
api_key="sk_live_..."
)
completion = client.chat.completions.create({
"model": "llama3.2",
"messages": [
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Explain embeddings in one sentence."}
],
"max_tokens": 256,
"temperature": 0.7,
})
print(completion["choices"][0]["message"]["content"])
print(completion.get("usage_source"))
print(completion.get("metrics", {}).get("tokens_per_second"))
completion["usage_source"] is:
"provider"when the upstream provider reported usage"gateway_estimated"when Nova AI estimated usage to keep the contract consistent
Example: Streaming Chat
from nova_ai import NovaAIClient, collect_chat_text
client = NovaAIClient(
api_key="sk_live_..."
)
stream = client.chat.completions.stream({
"model": "llama3.2",
"messages": [{"role": "user", "content": "Write three short tips."}]
})
for event in stream:
if event["type"] == "chunk":
choices = event["data"].get("choices", [])
if choices:
print(choices[0].get("delta", {}).get("content", ""), end="")
print()
print(collect_chat_text(client.chat.completions.stream({
"model": "llama3.2",
"messages": [{"role": "user", "content": "Summarize vectors in one line."}]
})))
Example: Embeddings
from nova_ai import NovaAIClient
client = NovaAIClient(
api_key="sk_live_..."
)
embedding = client.embeddings.create({
"model": "nomic-embed-text",
"input": "Nova AI"
})
print(len(embedding["data"][0]["embedding"]))
Example: Audio Transcription
from nova_ai import NovaAIClient
client = NovaAIClient(
api_key="sk_live_..."
)
transcript = client.audio.transcriptions.create(
file_path="./sample.wav",
model="whisper-1",
language="nl",
)
print(transcript["text"])
Example: Speech Synthesis
from nova_ai import NovaAIClient
client = NovaAIClient(
api_key="sk_live_..."
)
audio = client.audio.speech.create({
"model": "Qwen/Qwen3-TTS-12Hz-1.7B-Base",
"input": "Hello from Nova AI",
"task_type": "Base",
"ref_audio": "https://example.com/reference.wav",
"ref_text": "Exact transcript of the reference audio.",
"response_format": "wav",
})
with open("speech.wav", "wb") as target:
target.write(audio)
Included Methods
client.providers.list()client.models.list(limit=None, after=None)client.chat.completions.create(payload, config_id=None, request_id=None)client.chat.completions.stream(payload, config_id=None, request_id=None)client.embeddings.create(payload, config_id=None, request_id=None)client.audio.transcriptions.create(file_path=..., model=..., ...)client.audio.translations.create(file_path=..., model=..., ...)client.audio.speech.create(payload, config_id=None, request_id=None)client.audio.voices.list(config_id=None, request_id=None)
Audio Notes
client.audio.transcriptions.create()andclient.audio.translations.create()upload audio asmultipart/form-data.client.audio.speech.create()returns raw bytes.client.audio.voices.list()only exposes non-uploaded voices returned by the gateway.- The gateway enforces runtime scopes:
audio:transcribeaudio:translateaudio:synthesis
Why streaming uses for, not async for
For this Python SDK, a normal iterator is the simplest way to support streaming without extra dependencies. That means you can stream like this:
for event in client.chat.completions.stream({...}):
...
Using async for is also possible, but it usually means introducing an async HTTP client such as httpx or aiohttp, which makes the first version of the SDK heavier.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file datalabrotterdam_nova_sdk-1.5.4.tar.gz.
File metadata
- Download URL: datalabrotterdam_nova_sdk-1.5.4.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e41878f99a1753d98ef9a2adf5a22f2bde1e1d9f0fec8c7c6f2656510f22f143
|
|
| MD5 |
0448e13300cc52dae6b1719c59330e3e
|
|
| BLAKE2b-256 |
1e23b8e3fad6c0842c63ae07dc02d3744e514c5fbcb5e08c6be615aee9c94008
|
File details
Details for the file datalabrotterdam_nova_sdk-1.5.4-py3-none-any.whl.
File metadata
- Download URL: datalabrotterdam_nova_sdk-1.5.4-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
674956f71a42af788f2fb8fc5fc5d3d1eb8a6f7a54fd79573ac35c8c61d3fb02
|
|
| MD5 |
ef8ff8815a9a07f3cc79926b737c96eb
|
|
| BLAKE2b-256 |
33c302f09b6efe9323771e203577147c0534317660731b15052e8e353a0c4806
|