Skip to main content

The official Veyra Python SDK — sync + async, fully typed.

Project description

veyra-python

PyPI Python Versions License CI

The official Veyra Python SDK: sync + async clients, typed models, streaming, pagination, retries, and rich API exceptions.

Installation

pip install veyra

Quickstart (Sync)

import veyra

client = veyra.Veyra()
completion = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)

Quickstart (Async)

import asyncio
import veyra

async def main() -> None:
    async with veyra.AsyncVeyra() as client:
        completion = await client.chat.completions.create(
            model="gpt-5.4-mini",
            messages=[{"role": "user", "content": "Hello from async"}],
        )
        print(completion.choices[0].message.content)

asyncio.run(main())

Authentication

Set environment variable:

export VEYRA_API_KEY="veyra_sk_..."

Or pass explicitly:

client = veyra.Veyra(api_key="veyra_sk_...")

Resources at a glance

Namespace Method
client.chat.completions create(...)
client.completions create(...)
client.responses create(...)
client.embeddings create(...)
client.images.generations create(...)
client.audio.transcriptions create(...)
client.models list(), retrieve(id)
client.quota status(), list_plans(), list_public_plans()
client.billing.usage list(), daily_summary(), monthly_summary()
client.billing.profile retrieve(), upsert(...), access()
client.api_keys create(...), list(), update(...), revoke(...)
client.assistant chat(...)
client.health check(), ready()

Streaming

import veyra

client = veyra.Veyra()
with client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Count to 3"}],
    stream=True,
) as stream:
    for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="")

Error handling

import veyra

client = veyra.Veyra()
try:
    client.chat.completions.create(
        model="gpt-5.4-mini",
        messages=[{"role": "user", "content": "Hello"}],
    )
except veyra.RateLimitError as exc:
    print("Retry after:", exc.retry_after)
except veyra.APIError as exc:
    print(exc.status_code, exc.code, exc)

Pagination

for record in client.billing.usage.list(limit=100):
    print(record.model, record.total_tokens)

Retries and timeouts

client = veyra.Veyra(max_retries=4, timeout=30)
client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Hello"}],
    timeout=10,
)

Raw responses

raw = client.with_raw_response.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Hi"}],
)
print(raw.request_id)
print(raw.http_status)

Async streaming

import asyncio
import veyra

async def main() -> None:
    async with veyra.AsyncVeyra() as client:
        stream = await client.chat.completions.create(
            model="gpt-5.4-mini",
            messages=[{"role": "user", "content": "Count to 3"}],
            stream=True,
        )
        async with stream:
            async for chunk in stream:
                print(chunk.choices[0].delta.content or "", end="")

asyncio.run(main())

Full docs: docs/

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

tubox_veyra-1.0.0.tar.gz (60.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tubox_veyra-1.0.0-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file tubox_veyra-1.0.0.tar.gz.

File metadata

  • Download URL: tubox_veyra-1.0.0.tar.gz
  • Upload date:
  • Size: 60.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tubox_veyra-1.0.0.tar.gz
Algorithm Hash digest
SHA256 898b8aa0984bafc053736eec70588aec675985866cc3db2671ce87e6a0e7c197
MD5 54782d157b8a59e87e8e7c14c9b2389b
BLAKE2b-256 68b4c11512fb7a0295009f2b6767d7d9a9041f2ce6940281429a83e730380d75

See more details on using hashes here.

File details

Details for the file tubox_veyra-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tubox_veyra-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tubox_veyra-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b49ad6f97c40af58f254ad4fdaa45a3bd51180a6018d4ea22fcd6fad939d3216
MD5 2890720844c15dc486e7ade7250775b7
BLAKE2b-256 3135ec59667f57d62a8cd08b6918f2cafae820a19f5ea344b98b33663253916f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page