Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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 for loop
  • audio helpers for transcription, translation, speaker diarization, 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: Speaker Diarization

Returns who spoke when (time segments with a speaker label), not the words. Combine it with a verbose_json transcription to get a transcript per speaker.

from nova_ai import NovaAIClient

client = NovaAIClient(
    api_key="sk_live_..."
)

result = client.audio.diarizations.create(
    file_path="./meeting.wav",
    model="nemotron-3-diarization",
)

for segment in result["segments"]:
    print(f'{segment["speaker"]}: {segment["start"]}s - {segment["end"]}s')

Labels such as speaker_0 only mean something within one response or stream.

Example: Live Diarization

client.audio.diarizations.stream_url(model) builds the wss:// URL. The SDK has no WebSocket dependency, so bring your own client (here websockets), stream 16 kHz mono PCM16 binary frames, and send {"type": "end"} when done. The full event protocol is in the gateway's API docs (WS /v1/audio/diarization/stream).

import json
import threading

from websockets.sync.client import connect

# Raw 16 kHz mono PCM16, e.g. `ffmpeg -i meeting.mp3 -f s16le -ac 1 -ar 16000 meeting.pcm`
with open("meeting.pcm", "rb") as source:
    pcm = source.read()

url = client.audio.diarizations.stream_url("nemotron-3-diarization")
with connect(url, additional_headers={"Authorization": "Bearer sk_live_..."}) as ws:
    assert json.loads(ws.recv())["type"] == "ready"

    def send_audio():
        for offset in range(0, len(pcm), 3200):  # ~100 ms per frame
            ws.send(pcm[offset:offset + 3200])
        ws.send(json.dumps({"type": "end"}))

    threading.Thread(target=send_audio, daemon=True).start()
    for message in ws:
        event = json.loads(message)
        if event["type"] == "segment":
            print(event["speaker"], event["start"], event["end"])
        elif event["type"] in ("done", "error"):
            break

Example: Speech Synthesis

from nova_ai import NovaAIClient

client = NovaAIClient(
    api_key="sk_live_..."
)

audio = client.audio.speech.create({
    "model": "tts-1",
    "input": "Hello from Nova AI",
    "voice": "alloy",
    "response_format": "wav",
})

with open("speech.wav", "wb") as target:
    target.write(audio)

List the voices a model offers (values for voice):

voices = client.audio.voices.list("kokoro")["voices"]

Included Methods

  • client.providers.list()
  • client.models.list(limit=None, after=None)
  • client.chat.completions.create(payload, provider_configuration_id=None, request_id=None)
  • client.chat.completions.stream(payload, provider_configuration_id=None, request_id=None)
  • client.embeddings.create(payload, provider_configuration_id=None, request_id=None)
  • client.audio.transcriptions.create(file_path=..., model=..., ...)
  • client.audio.translations.create(file_path=..., model=..., ...)
  • client.audio.diarizations.create(file_path=..., model=..., provider_configuration_id=None, request_id=None)
  • client.audio.diarizations.stream_url(model)
  • client.audio.speech.create(payload, provider_configuration_id=None, request_id=None)
  • client.audio.voices.list(model, provider_configuration_id=None, request_id=None)

Audio Notes

  • client.audio.transcriptions.create(), client.audio.translations.create() and client.audio.diarizations.create() upload audio as multipart/form-data.
  • client.audio.speech.create() returns raw bytes.
  • The gateway enforces runtime scopes:
    • audio:transcribe
    • audio:translate
    • audio:diarize (upload and live stream)
    • audio:synthesis (speech and voice listing)

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.

Metadata

Release files for datalabrotterdam-nova-sdk 1.6.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datalabrotterdam-nova-sdk 1.6.0.dev1
File Size Uploaded Provenance Actions
datalabrotterdam_nova_sdk-1.6.0.dev1.tar.gz 12.3 kB Without provenance Details for datalabrotterdam_nova_sdk-1.6.0.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datalabrotterdam-nova-sdk 1.6.0.dev1
File Interpreter ABI Platform Actions
datalabrotterdam_nova_sdk-1.6.0.dev1-py3-none-any.whl Python 3 none any Details for datalabrotterdam_nova_sdk-1.6.0.dev1-py3-none-any.whl

Total release size: 23.7 kB

Release files / datalabrotterdam_nova_sdk-1.6.0.dev1.tar.gz

Download URL datalabrotterdam_nova_sdk-1.6.0.dev1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b0befba9ccce7669ad5c638ff1d193c29df35cb320260431e6ed942ecbe0da76
BLAKE2b-256 checksum
How to use checksums
2a61db9d8fd55018ca4319930c0d88aed34bb6402360de777a54af9f943f6b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / datalabrotterdam_nova_sdk-1.6.0.dev1-py3-none-any.whl

Download URL datalabrotterdam_nova_sdk-1.6.0.dev1-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
754dc6ff13ff722a566f108240ae734882a6e42f8bd2eeb206b4f8d9631ce952
BLAKE2b-256 checksum
How to use checksums
b1f619c9acde83408abad51525441c4dce8978869a64a95263e58a5234f6cd33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for datalabrotterdam-nova-sdk 1.6.0.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page