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.2.0.tar.gz (81.3 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.2.0-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for velmhq-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0efd485a4026d555a1afffc0f4b9a261591525cdfc6b37b4fcf66011e92d5114
MD5 d3a7ec1f35d2e6752ae5dc2cd71abd94
BLAKE2b-256 35822f8906ed861ce5a11ae505c379960576118b703cad356e746c4409458fdd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for velmhq-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 542d201c5583eefe8eb72c4026c1c8b1c2550f93a134337bb0dbcd8061423500
MD5 1205ee5c54e6de5306644d6dcb85b813
BLAKE2b-256 d94324f550c71ac4b89837f0327fb6c97dde516a0f6951e15b067523f91c6035

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