Skip to main content

Python SDK for the Velm API.

Project description

velmhq

Python SDK for the Velm API.

Status: pre-release. The public surface is stable in shape but the underlying API is still evolving. Pin a version until the 1.0.0 release.

Install

pip install velmhq
# or
uv add velmhq

The PyPI distribution name is velmhq because the bare velm is already published by an unrelated project.

Usage

from velmhq import Velm

velm = Velm(api_key="vk_test_...")

# Invoke an agent and wait for the result.
run = velm.run("support-bot", {"question": "How do I reset my password?"})
print(run.text)

# Capture a thumbs-down to feed the improvement loop.
velm.feedback.capture(
    run_id=run.id,
    feedback_key=run.id,
    event_type="thumbs_down",
    conversation_text=transcript,
    original_response=bad_response,
    metadata={"surface": "sdk"},
)

The async client mirrors the sync surface:

import asyncio
from velmhq import AsyncVelm

async def main() -> None:
    async with AsyncVelm(api_key="vk_test_...") as velm:
        run = await velm.run("support-bot", {"question": "..."})
        print(run.text)

asyncio.run(main())

Multi-turn conversations

Pass the same conversation_id across runs and the agent replays the prior turns, so it has the full context. The id is caller-minted - any stable string. Omit it for a one-shot run.

import uuid

conversation_id = str(uuid.uuid4())

turn1 = velm.runs.create("support-bot",
    input={"message": "I was double-charged last month."},
    conversation_id=conversation_id)

turn2 = velm.runs.create("support-bot",
    input={"message": "and what about this month?"},
    conversation_id=conversation_id)

# Inspect every run in the conversation.
for run in velm.runs.list(conversation_id=conversation_id):
    print(run.id, run.status, run.created_at)

Errors

The SDK raises typed exceptions on non-2xx responses. Branch on the class, not the message string.

from velmhq import (
    AuthenticationError,
    BillingError,
    RateLimitError,
    VelmError,
)

try:
    velm.feedback.capture(...)
except RateLimitError as err:
    print(f"rate limited; retry after {err.retry_after_ms}ms")
except BillingError as err:
    print(err.message)  # points at the billing settings page
except AuthenticationError:
    print("invalid API key")
except VelmError as err:
    print(f"{err.code}: {err.message}")

Testing

velmhq.testing.MockVelm is a scriptable fake for unit tests in your own code. It runs the real SDK code path under a fake transport, so retries, idempotency keys, and error mapping all behave as in production.

from velmhq.testing import MockVelm

def test_my_handler() -> None:
    velm = MockVelm()
    velm.respond_next({"feedbackId": "fb_1"})

    my_handler(velm)

    assert len(velm.calls) == 1
    assert velm.calls[0].url.endswith("/feedback")

Runtime support

Works on CPython 3.10 through 3.13. Uses httpx for HTTP and pydantic v2 for typed models. Both sync (Velm) and async (AsyncVelm) clients are provided; pick whichever fits your application's runtime.

Documentation

Full reference at velm.run/docs.

License

MIT. See LICENSE.

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

velmhq-0.3.0.tar.gz (86.7 kB view details)

Uploaded Source

Built Distribution

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

velmhq-0.3.0-py3-none-any.whl (51.9 kB view details)

Uploaded Python 3

File details

Details for the file velmhq-0.3.0.tar.gz.

File metadata

  • Download URL: velmhq-0.3.0.tar.gz
  • Upload date:
  • Size: 86.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for velmhq-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9514913281b6c256d953b7b177f8b86b15bbe27b7779be7ed984532e74e15525
MD5 803ed76286dbc6020d03072e894944a7
BLAKE2b-256 f05731a5bb5e0aa511cd882e003c00b4034d4816d997d528b11d618909744104

See more details on using hashes here.

File details

Details for the file velmhq-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: velmhq-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 51.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for velmhq-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2590707e1b05c86ad1c1d73836c6330d035b1384ba680a0b11699fb511971591
MD5 1d83958bb9c3378b3bc5c15583dcad3c
BLAKE2b-256 6b335b859af87dc738434e3052d6b1be7adbdea085471649196c92f3cdc32e6f

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