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
Release history Release notifications | RSS feed
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 velmhq-0.1.0.tar.gz.
File metadata
- Download URL: velmhq-0.1.0.tar.gz
- Upload date:
- Size: 81.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3f8b46eaacdcdf9e8bdc1c445c7d8d3b403e4ad00b04291bdbee5971513c4b8
|
|
| MD5 |
51ffcebccee1fb9bc33ec225c42512e2
|
|
| BLAKE2b-256 |
17d5615abd70ad30e90764a24dff4715805a89ef4ee993395f20d5c53814f28b
|
File details
Details for the file velmhq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: velmhq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84d5128a3f78fa3feda4f04b10098da426c14a99bb15215dde0ddb9144150a9e
|
|
| MD5 |
54dea0fa487bacbedcecffd385df54ce
|
|
| BLAKE2b-256 |
9e066d56c3dbc853793901586956f47dd0a70c1cacb23217d452b04d830b8620
|