hot-dev
Official Python SDK for the Hot Dev API.
- PyPI distribution:
hot-dev - Import package:
hot - Tested on Python 3.10 through 3.15
Install
pip install hot-dev
Quick Start
import os
from hot import HotClient
hot = HotClient(token=os.environ["HOT_API_KEY"])
# base_url defaults to https://api.hot.dev.
# For local development with `hot dev`, pass base_url="http://localhost:4681".
for event in hot.streams.subscribe_with_event(
{
"event_type": "team-agent:ask",
"event_data": {
"session_id": "web:chat:demo",
"user_id": "web:user:demo",
"user_name": "Demo User",
"question": "what is blocking launch?",
},
}
):
if event["type"] == "stream:data":
print(event["data_type"], event.get("payload"))
if event["type"] == "run:stop":
print(event.get("run", {}).get("result"))
break
The client closes its underlying HTTP connection cleanly when used as a context manager:
with HotClient(token=os.environ["HOT_API_KEY"]) as hot:
event = hot.events.publish(
{
"event_type": "team-agent:ask",
"event_data": {"question": "what changed?"},
}
)
print(event["stream_id"])
Authenticated clients should run server-side. Browser apps and public notebooks should call your own backend route instead of exposing a Hot API key. Administrative runtime endpoints require an API key with appropriate grants. Sessions and service keys are permission-scoped and are mainly for event publishing and stream reads.
When code has a run id but does not need the full stream, wait on its durable
terminal snapshot. timeout bounds the whole wait, including reconnects:
run = hot.runs.wait(run_id, timeout=300)
print(run["result"])
When a run returns a background task id, wait through the durable task resource:
task = hot.tasks.wait(task_id, timeout=300)
print(task["result"])
The task waiter receives the latest persisted state first and reconnects, so it
cannot miss a task that completed before subscription. A failed, cancelled, or
timed-out task raises HotTaskError with the final task record.
To coordinate several tasks, wait on each one (hot.tasks.wait), for example
from a thread pool or with asyncio.gather on AsyncHotClient. The task's
parent stream also emits durable task:update events, but a plain
streams.subscribe ends at the API's 5-minute subscription limit.
Waiters and reconnects
runs.wait, tasks.wait, streams.wait_for_run_result, events.call_hot
and streams.subscribe_with_event share one reconnect policy:
timeoutis an absolute deadline over connecting, reading, and backoff. It fires even while the server keeps sending keepalives.subscribe_with_eventtakes an optionaltimeout; without one it has no deadline.- Permanent errors (any 4xx except 408 and 429, including
HotKeyScopeError) raise at once. - Transport errors, 408, 429 and 5xx reconnect with jittered exponential
backoff (0.25 s up to 10 s), honouring
retry_after. A backoff that would cross the deadline raisesTimeoutErrorinstead. max_attempts(default 5) counts consecutive failed connections. The API closes every subscription 5 minutes after it opens, withstream:complete; explicitstream:completerollovers reconnect at once and do not count, so long runs can be awaited for as long astimeoutallows. Unexpected premature stream closes withoutstream:completeback off and count againstmax_attempts.- A run with status
pending_retryis not final, whatever the event: the waiter follows the handler's retry run (linked byretry_run_idororigin_run_id). Hot can replay a retried attempt asrun:failwith statusfailedbefore the retry run exists; when itsretry_attemptshows a scheduled retry, the waiter holds that failure for 5 seconds (or untiltimeout) and raisesHotRunError(aRuntimeErrorsubclass) only if no retry run appears.subscribe_with_eventyields thatrun:failand ends after the same grace. on_chunkreceivesstream:datatext in order, including chunks the server delivers beforerun:start.
Async Usage
import os
from hot import AsyncHotClient
async with AsyncHotClient(token=os.environ["HOT_API_KEY"]) as hot:
event = await hot.events.publish(
{
"event_type": "team-agent:ask",
"event_data": {"question": "what changed?"},
}
)
print(event["stream_id"])
Async streaming is supported the same way:
async with AsyncHotClient(token=os.environ["HOT_API_KEY"]) as hot:
async for event in hot.streams.subscribe_with_event(
{
"event_type": "team-agent:ask",
"event_data": {"question": "what changed?"},
}
):
print(event["type"], event)
AsyncHotClient exposes the same resource namespaces as HotClient.
Errors
Non-2xx API responses raise HotApiError with structured fields:
from hot import HotApiError
try:
hot.projects.get("missing-project")
except HotApiError as error:
print(error.status_code, error.code, error.request_id, error.retry_after)
A call made with the wrong kind of key raises HotKeyScopeError (a
HotApiError with status 403 and code key_scope_mismatch). Its
required_scope is "org" for hot.orgs and hot.api_keys, and "env" for
every runtime resource.
Retries
JSON requests are retried automatically (at most twice, bounded by the client's configured read timeout) when the API responds:
429with aretry_after(including0, integer seconds, or HTTP-date),502,503, or504on idempotent requests (GET,HEAD,PUT,DELETE),503with error codeevent_publish_in_progressonPOST(for example, concurrent retries ofevents.publishwith the same client-suppliedevent_id).
Other errors (including 409 event_id_conflict when an event_id is reused
with different parameters) are raised as-is. Raw requests (request_raw,
uploads, downloads) are never retried; waiters follow the reconnect policy
above.
Resources
HotClient mirrors the Hot API resources:
hot.status()— public, unauthenticated server health check (GET /status; does not sendAuthorization)hot.events— publish (pass an optionalevent_idfor idempotent retries; conflicting reuse returns409 event_id_conflict), list, get, inspect event runs, and call Hot functions withcall_hot(fn, args)hot.streams— subscribe to run and task updates, wait for run results, and publish events atomically (reconnects automatically across the 5-minute SSE timeout; passreconnect=Falseto opt out)hot.runs— list (filter bystatus,type,time_range,project_id,stream_id,function,limit,offset), inspect, subscribe to, and wait for durable runshot.tasks— get, subscribe to, and wait for durable background taskshot.files— upload, download (download_streamfor large files), list, and delete files (including multipart uploads)hot.projects— create, list, update, activate, deactivate, and delete projectshot.builds— upload, download (download_stream), deploy, and look up live/deployed buildshot.blobs— download large payloads spilled to blob storage (download_streamstreams them); needs an environment API keyhot.context— manage encrypted project context variableshot.domains— register, verify, list, and delete custom domainshot.sessions— create and revoke scoped sessionshot.service_keys— create and revoke scoped service keyshot.org— view the environment's usage and limitshot.env— read environment info, subscribe to environment events, and purge call traceshot.orgs— with an org API key: sub-organizations, their environments and API keys, account usage, andorgs.env(org_id, env_id)for projects, builds and context in an environmenthot.api_keys— with an org API key: get, narrow, rotate, and revoke API keys it issued (statuscan beactive,revoked,disabled,expired,issuer_inactive, orsuspended)
Use hot.request(...) or hot.request_raw(...) as an escape hatch for /v1
API endpoints that do not yet have a resource helper. Paths are resolved under
/v1 automatically (pass "/runs" or "runs", not "/v1/runs"); use
hot.status() for the unversioned GET /status route.
hot.env.subscribe() requires API key credentials and a live API pub/sub
backend; local API servers without pub/sub return a 503. subscribe_with_event
reconnects across the API's 5-minute SSE timeout and stops after the terminal
run correlated to the event it published. Unrelated runs on the same stream do
not end the iterator.
Customizing the HTTP Client
Without timeout or client, requests time out after 60 s per read and 10 s
to connect; pass timeout=httpx.Timeout(None) to disable that. Streams and
waiters set their own timeouts. Note that timeout= is ignored when you pass a
custom client= — configure timeouts on your httpx.Client /
httpx.AsyncClient instead.
HotClient and AsyncHotClient accept an httpx.Client (or
httpx.AsyncClient) via the client= argument. Use this to configure retries,
proxies, or custom transports:
import httpx
from hot import HotClient
http_client = httpx.Client(
timeout=httpx.Timeout(connect=5.0, read=60.0, write=30.0, pool=5.0),
transport=httpx.HTTPTransport(retries=3),
)
hot = HotClient(token=os.environ["HOT_API_KEY"], client=http_client)
When you pass your own client, the SDK does not close it on exit.
Downloads
files.download, builds.download and blobs.download read the whole body into
memory. For large files, stream instead:
with hot.files.download_stream(file_id) as response, open("out.bin", "wb") as out:
for chunk in response.iter_bytes():
out.write(chunk)
blobs.download_stream(blob_ref_id) works the same way.
AsyncHotClient offers the same with async with and response.aiter_bytes().
Casing Policy
Core API request and response payloads use the Hot API wire format:
event_type, event_data, stream_id, and so on. SDK-only options use Python
style names such as base_url and timeout.
The SDK never transforms user-owned payloads such as event_data.
Type Hints
The package ships with py.typed, so editors and type checkers will pick up
the public API. Request and response payloads are currently typed as plain
dict[str, Any] — keys follow the Hot API wire format documented above. Strict
TypedDict shapes generated from the Hot API OpenAPI spec are planned for a
future release.
Org API
Requires Hot 3.0.1 or later. An org API key (created by an administrator of the parent organization in the
App) provisions sub-organizations, their environments, and environment API
keys. Org keys only call hot.orgs and hot.api_keys; environment keys,
service keys, and sessions only call runtime resources. Either kind of key on
the wrong routes raises HotKeyScopeError.
import os
import uuid
from hot import HotClient
with HotClient(token=os.environ["HOT_ORG_API_KEY"]) as org:
request_id = uuid.uuid4().hex[:24]
sub_org = org.orgs.create(
{
"name": "Customer",
"slug": f"customer-{request_id}", # 32 characters or fewer
"external_id": "customer-123",
"idempotency_key": request_id, # reuse it when retrying this request
}
)
org_id, env_id = sub_org["org"]["org_id"], sub_org["env_id"]
key = org.orgs.create_env_api_key(
org_id,
env_id,
{"description": "Customer backend", "permissions": {"*:*": ["*"]}},
)
# Projects, builds and context in the sub-organization's environment, with the org key.
org.orgs.env(org_id, env_id).projects.create({"name": "agent"})
with HotClient(token=key["token"]) as customer:
print(customer.env.get())
| Method | Route |
|---|---|
orgs.list(limit=, offset=) |
GET /v1/orgs (list envelope) |
orgs.create(body) |
POST /v1/orgs: returns org, env_id, created |
orgs.get(org_id) / orgs.update(org_id, {"state": ...}) |
GET/PATCH /v1/orgs/{org_id} (active, suspended, archived) |
orgs.usage(parent_org_id) |
GET /v1/orgs/{org_id}/usage (account usage; parent organization only) |
orgs.purge_calls(org_id, include_sub_orgs=False) |
DELETE /v1/orgs/{org_id}/calls |
orgs.list_envs / create_env / get_env |
/v1/orgs/{org_id}/envs[/{env_id}] (create is idempotent by name) |
orgs.list_api_keys / create_api_key |
/v1/orgs/{org_id}/api-keys (org keys) |
orgs.list_env_api_keys / create_env_api_key |
/v1/orgs/{org_id}/envs/{env_id}/api-keys |
api_keys.get / update / revoke / rotate(overlap_seconds=) |
/v1/api-keys/{key_id}[/rotate] |
orgs.env(org_id, env_id).projects / .builds / .context |
/v1/orgs/{org_id}/envs/{env_id}/... |
A minted or rotated key's token is returned only once. Minted grants must fit
inside the org key's own grants for that environment. Revoking or narrowing an
org key restricts every key, service key, and session issued under it.
hot.org.usage() (runtime) reports one environment's consumption, with
env_id and usage_scope: "environment"; its limits come from the billing
account. Use orgs.usage(parent_org_id) with an org key for the account total.
Local Development
python -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
ruff check .
pytest
python -m build
Org API integration tests
integration/suborg_fixture.py creates an owned disposable database and
loopback API server, seeds an org API key and a root environment key, checks
the live OpenAPI operations against tests/openapi_operations.json, and runs
the given test command. It removes only its own resources and never uses
deployed credentials. It needs Python 3 and a Hot CLI built from the revision
in integration/hot-server.ref. For PostgreSQL, also install Docker and psql
and provide that hot checkout (default: sibling hot). Migrations use a
non-superuser schema owner; the API uses a distinct non-owner
NOSUPERUSER NOBYPASSRLS login with RLS enforcement.
python3 integration/suborg_fixture.py --hot ../hot/target/debug/hot --backend postgres -- \
.venv/bin/python -m pytest tests/test_suborg_integration.py -v
# For SQLite, use --backend sqlite.
Coverage includes sub-organization and environment provisioning and idempotency, identical
project names in siblings, foreign-ID and stream denial, root runtime
isolation, org/environment key separation (HotKeyScopeError), account and
environment usage, provisioning projects and context through orgs.env,
restricted keys, key rotation, narrowing and revocation, service/session
issuance and revocation, descendants of a revoked or narrowed org key, and sub-organization
suspension and resumption. See the validation record.
Related
License
Apache-2.0
Metadata
Release files for hot-dev 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hot_dev-1.4.0.tar.gz | 35.2 kB | With provenance | Details for hot_dev-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hot_dev-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for hot_dev-1.4.0-py3-none-any.whl |
Total release size: 74.3 kB
Release files / hot_dev-1.4.0.tar.gz
| Download URL | hot_dev-1.4.0.tar.gz |
|---|---|
| Size | 35.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ab2f67e1abb7698a3749732b523fd4f4f4ad1157b2ca73b5fbab860a2885988
|
|
BLAKE2b-256 checksum How to use checksums |
2607a455d42be909b667df8cc95beb5c7e0c50cfc9f7de027a1d460e49b21d8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / hot_dev-1.4.0-py3-none-any.whl
| Download URL | hot_dev-1.4.0-py3-none-any.whl |
|---|---|
| Size | 39.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01a0af2c6e349c1b8055f4a48dc149649b6b1698254d8f3de55ee51a9ecefc89
|
|
BLAKE2b-256 checksum How to use checksums |
13082c6ab6528c96a6907d40543cb95f88328db35e06f5602fef2a48005a2df9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for hot-dev 1.4.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hot_dev-1.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA 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.