Strait Python SDK
Project description
Python SDK for the Strait API
The official Python SDK for Strait -- an open-source job execution and workflow orchestration platform for humans and AI agents. Define jobs, build DAG workflows, run durable AI agents with cost tracking, and manage the full run lifecycle from Python.
Sync and async clients, 19 domain services (~186 operations), authoring DSL, composition helpers, FSM state machines, and PEP 561 type hints.
Website | Platform Repo | Documentation | PyPI
Installation
pip install strait-python
Requires Python 3.11+.
Quick Start
from strait import Client
client = Client(base_url="https://api.strait.dev", api_key="your-key")
# List jobs
jobs = client.jobs.list()
# Trigger a job
run = client.jobs.trigger(job["id"], {"payload": {"key": "value"}})
# Get a run
run = client.runs.get(run["id"])
Async
from strait import AsyncClient
async with AsyncClient.from_env() as client:
jobs = await client.jobs.list()
run = await client.jobs.trigger("job-id", {"payload": {}})
Configuration
Three ways to create a client:
# From environment variables (STRAIT_BASE_URL, STRAIT_API_KEY)
client = Client.from_env()
# From strait.json file (token always from STRAIT_API_KEY env var)
client = Client.from_file()
# Inline
client = Client(base_url="https://api.strait.dev", api_key="your-key")
All methods work with AsyncClient too. See Configuration Guide for details.
Features
Domain Operations (19 Services)
All 186 API operations organized into typed service classes:
| Service | Examples |
|---|---|
client.jobs |
list, create, get, update, delete, trigger, bulk_trigger |
client.runs |
list, get, delete, replay, bulk_cancel, get_dlq |
client.workflows |
list, create, trigger, get_diff, get_policy |
client.workflow_runs |
list, pause, resume, approve_step, skip_step |
client.deployments |
list, create, finalize, promote, rollback |
client.sdk_runs |
complete_run, heartbeat_run, checkpoint_run |
client.rbac |
list_roles, create_member, seed_roles |
| + 12 more | environments, secrets, api_keys, webhooks, ... |
Authoring DSL
Define jobs, workflows, and AI agents with a type-safe DSL:
from strait.authoring import define_job, define_workflow, JobOptions, WorkflowOptions
from strait.authoring import job_step, approval_step
wf = define_workflow(WorkflowOptions(
name="Order Pipeline", slug="order-pipeline", project_id="proj-1",
steps=[
job_step("validate", "validate-job"),
job_step("charge", "charge-job", depends_on=["validate"]),
approval_step("approve", depends_on=["charge"]),
job_step("ship", "ship-job", depends_on=["approve"]),
],
))
See Authoring Guide for AI agents, event definitions, RunContext, and test harness.
Composition Helpers
from strait.composition import with_retry, wait_for_run, paginate, RetryOptions
# Retry with exponential backoff
result = with_retry(lambda: client.jobs.trigger("j1", payload), RetryOptions(attempts=5))
# Wait for a run to complete
run = wait_for_run(
get_run=lambda rid: client.runs.get(rid),
get_status=lambda r: r["status"],
run_id="run-1",
)
See Composition Guide for cost budgets, checkpoint resume, pagination, and more.
Error Handling
All errors inherit from StraitError with typed exceptions for each HTTP status:
from strait import NotFoundError, RateLimitedError
try:
job = client.jobs.get("nonexistent")
except NotFoundError as e:
print(f"Not found: {e} (status={e.status})")
except RateLimitedError as e:
print(f"Rate limited, retry after backoff")
See Error Handling Guide for the full exception hierarchy.
Middleware
from strait import Client, Middleware
mw = Middleware(
on_request=lambda ctx: print(f"-> {ctx.method} {ctx.url}"),
on_response=lambda ctx: print(f"<- {ctx.status} ({ctx.duration_ms}ms)"),
)
client = Client.from_env(middleware=[mw])
FSM State Machines
from strait.fsm import transition_run, RunStatus, RunEvent
next_status = transition_run(RunStatus.EXECUTING, RunEvent.COMPLETE)
assert next_status == RunStatus.COMPLETED
Documentation
| Guide | Description |
|---|---|
| Configuration | Client creation, auth types, strait.json, env vars |
| Authoring | Jobs, workflows, agents, RunContext, test harness |
| Composition | Retry, wait, paginate, cost budget, checkpoint resume |
| Errors | Exception hierarchy, HTTP error mapping |
| Examples | Runnable code examples for all major features |
Development
make bootstrap # Create venv + install deps
make lint # Run ruff (lint + format check)
make typecheck # Run mypy (strict mode)
make test # Run pytest with coverage
make run-all # lint + typecheck + test
See CONTRIBUTING.md for the full contributor guide.
License
MIT
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 strait_python-0.1.1.tar.gz.
File metadata
- Download URL: strait_python-0.1.1.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dbb4577be57684d821f0bb7fb51b42aa6d040ac3cf3fc37fd859378d3f71316
|
|
| MD5 |
e867ab7560edba8997d0c8eccccfc348
|
|
| BLAKE2b-256 |
c508724ddad430320b51caacf33dda7cabfa30faa61310d0f601a980f47704b9
|
Provenance
The following attestation bundles were made for strait_python-0.1.1.tar.gz:
Publisher:
publish.yml on strait-dev/strait-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strait_python-0.1.1.tar.gz -
Subject digest:
7dbb4577be57684d821f0bb7fb51b42aa6d040ac3cf3fc37fd859378d3f71316 - Sigstore transparency entry: 1428875087
- Sigstore integration time:
-
Permalink:
strait-dev/strait-python@6cf8739ec51e0b815a32bea5c220ca058c1d69b1 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/strait-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cf8739ec51e0b815a32bea5c220ca058c1d69b1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file strait_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: strait_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 56.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9564758df9f31e316ea4f0e0507bcaf8ce33976e2c96eef64f1ce113aa617fe
|
|
| MD5 |
d9259390c5883582d3aac2f887cf118e
|
|
| BLAKE2b-256 |
d42b3d8981a6c884ebea02b889c66c6916886ecc506438ad073571d472d546da
|
Provenance
The following attestation bundles were made for strait_python-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on strait-dev/strait-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strait_python-0.1.1-py3-none-any.whl -
Subject digest:
b9564758df9f31e316ea4f0e0507bcaf8ce33976e2c96eef64f1ce113aa617fe - Sigstore transparency entry: 1428875090
- Sigstore integration time:
-
Permalink:
strait-dev/strait-python@6cf8739ec51e0b815a32bea5c220ca058c1d69b1 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/strait-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cf8739ec51e0b815a32bea5c220ca058c1d69b1 -
Trigger Event:
push
-
Statement type: