This is the official Python SDK for Hatchet, a distributed, fault-tolerant task queue. The SDK allows you to easily integrate Hatchet's task scheduling and workflow orchestration capabilities into your Python applications, supporting the development of mission-critical AI agents, durable workflows, and background tasks. It is actively maintained, with regular updates and a focus on durability and scalability.
pip install hatchet-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the Hatchet client using environment variables for the API token and host, defines a simple task with the `@hatchet.task()` decorator, registers it with a worker, and starts the worker to process incoming tasks. Replace 'YOUR_HATCHET_CLIENT_TOKEN' with your actual token.
Update string-based timeouts to `datetime.timedelta` objects.
Replace direct usage of protobuf objects with their corresponding Python enum equivalents.
Prefix asynchronous method calls with `aio_`.
Update `max_runs` parameter to `slots` when configuring workers.
Update task function signatures to accept `input` and `context` arguments and use the `@hatchet.task()` decorator.
Upgrade your Hatchet engine to V1 or later to ensure compatibility with the V1 Python SDK.
Ensure your task's `input_validator` Pydantic model explicitly defines all fields used in concurrency keys.
Rewrite blocking operations (e.g., API calls with `requests`, synchronous database drivers) to their asynchronous equivalents (e.g., `aiohttp`, `asyncpg`), or offload CPU-bound tasks to a separate thread or process using `asyncio.to_thread()` or `ProcessPoolExecutor`.
Obtain a valid API token from the Hatchet dashboard or your self-hosted instance and set it as an environment variable: `export HATCHET_CLIENT_TOKEN="<your-api-token>"`. Alternatively, pass the token directly when initializing the `Hatchet` client: `hatchet = Hatchet(token="<your-api-token>")`.
Install the Hatchet SDK using pip: `pip install hatchet-sdk`. If using Poetry, use `poetry add hatchet-sdk`. Ensure you are running your script in the correct Python environment where the package was installed.
Verify the Hatchet engine is running and accessible. Check the `HATCHET_CLIENT_HOST_PORT` environment variable to ensure it points to the correct host and port (e.g., `localhost:7070`). If self-hosting, ensure TLS settings (`HATCHET_CLIENT_TLS_STRATEGY`) match the server's configuration; for local development, you might set `HATCHET_CLIENT_TLS_STRATEGY=none`. Check network connectivity and firewall rules.
No dependency data recorded yet.