TaskForceAI Python SDK
Project description
TaskForceAI Python SDK
The official Python client for TaskForceAI's multi-agent orchestration platform.
- ✅ Sync + async clients powered by
httpx - ✅ Automatic authentication with your TaskForceAI API key
- ✅ Convenience helpers for polling task completion
- ✅ Rich error handling with status codes and retry-ready exceptions
Installation
python -m pip install taskforceai
Quick Start
from taskforceai import TaskForceAIClient
client = TaskForceAIClient(api_key="your-api-key")
task_id = client.submit_task("Analyze the security posture of this repository.")
status = client.wait_for_completion(task_id)
print(status["result"])
# Bring your own Vercel AI Gateway key (unlocks premium models)
task_id = client.submit_task(
"Draft a quarterly strategy update.",
vercel_ai_key="sk-vercel-your-gateway-key",
)
# Forward arbitrary TaskForceAI orchestration options
task_id = client.submit_task(
"Do a full repository risk review",
options={"agents": 4, "budget": 12},
)
Async Variant
import asyncio
from taskforceai import AsyncTaskForceAIClient
async def main() -> None:
async with AsyncTaskForceAIClient(api_key="your-api-key") as client:
result = await client.run_task("Summarize the latest launch notes.")
print(result["result"])
asyncio.run(main())
### Streaming Task Updates
```python
from taskforceai import TaskForceAIClient
client = TaskForceAIClient(api_key="your-api-key")
stream = client.run_task_stream("Map open security issues", poll_interval=0.5)
for status in stream:
print(f"{status['status']}: {status.get('result')}")
# Cancel locally if needed
# stream.cancel()
Async projects can use AsyncTaskForceAIClient.stream_task_status() and iterate with
async for status in stream for non-blocking workflows.
## API Surface
Both clients expose the same methods:
- `submit_task(prompt, *, options=None, silent=None, mock=None, vercel_ai_key=None) -> str`
- `get_task_status(task_id) -> dict`
- `get_task_result(task_id) -> dict`
- `wait_for_completion(task_id, poll_interval=2.0, max_attempts=150, on_status=None) -> dict`
- `run_task(prompt, ..., on_status=None) -> dict`
- `stream_task_status(task_id, ..., on_status=None) -> Iterator`
- `run_task_stream(prompt, ..., on_status=None) -> Iterator`
### Response Hooks & Rate-Limit Telemetry
Both clients accept `response_hook=` in their constructors. The hook is invoked with the
raw `httpx.Response` (headers included) for every request, making it easy to track
rate-limit headers, request IDs, or emit custom metrics without wrapping the SDK.
All responses mirror the REST API payloads. Errors raise `TaskForceAIError`, which includes `status_code` for quick branching.
## Development
```bash
python -m pip install -e "packages/python-sdk[dev]"
pytest packages/python-sdk/tests
ruff format packages/python-sdk/src packages/python-sdk/tests -q
ruff check packages/python-sdk/src packages/python-sdk/tests
mypy --config-file packages/python-sdk/pyproject.toml packages/python-sdk/src
License
MIT
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
taskforceai-0.3.1.tar.gz
(12.0 kB
view details)
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 taskforceai-0.3.1.tar.gz.
File metadata
- Download URL: taskforceai-0.3.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c0d7091b54dfe128d9df5f3b472bd91aef555e7ce1225bb182d95ffd8d27cd
|
|
| MD5 |
92632412bb9901f9bf943a0d0293cf5b
|
|
| BLAKE2b-256 |
64ea985d4d0820ebc45646824a864a2d2842a597b144c81f85e2d4af67bafed6
|
File details
Details for the file taskforceai-0.3.1-py3-none-any.whl.
File metadata
- Download URL: taskforceai-0.3.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c35b22a77a02bd8d8462411182e926c279d891e23ac7a566e497f8f4d1773ef5
|
|
| MD5 |
ef6e4c8a46073ed4ad9a3729a07bba0d
|
|
| BLAKE2b-256 |
42393e226f1896a8c77fe474c7a4adb6fd3f3688b68b1566c178c0a375715d5d
|