Python quickstart
Before you start
If you only need the smallest runnable example, start with First workflow in five minutes. This page adds install verification, trace reading, optional OpenAI, error handling, and remote server mode in one sitting.
Read 03 Anatomy of a workflow so terms like step, run input, and result.output are already familiar.
Concept
The Python SDK exposes idiomatic Agent and Workflow types that serialize to the ArcFlow workflow specification and call the in-process Rust runtime by default. You declare agents and step order in Python; arcflow-core executes the graph, invokes providers, and emits trace events.
Without a provider= argument, run() uses the default in-process agent backend. No OPENAI_API_KEY is required on that path. Passing runtime="http://localhost:8080" targets arcflow-server instead while keeping the same declaration code.
Install
From the repository root:
Confirm the package loads:
See Install and build for platform notes (macOS, Linux, Windows) and troubleshooting.
Example: agent and workflow
Save as quickstart.py:
Run:
You should see step_count == 2, status of completed, and non-empty output.
Reading the result
WorkflowResult fields used most often:
| Field | Meaning |
|---|---|
output | Text from the final step |
run_id | UUID for this run; use with workflow.trace() or CLI |
step_count | Number of steps executed |
status | Terminal status string (typically completed) |
trace_events | Tuple of metadata-only trace event dicts |
Trace payloads follow trace data policy rules: no raw prompts, tool values, or credentials. See Trace data policy rules and Trace events (normative) for event shapes.
Structured trace via workflow.trace()
After run(), the workflow object exposes a parsed trace:
Calling trace() before run() raises TraceNotFoundError.
Optional: real LLM with OpenAI
When you have an API key, pass a provider to run():
Supported environment variables for other providers: ANTHROPIC_API_KEY, GEMINI_API_KEY with Anthropic and Gemini classes from arcflow.
Provider failures raise ProviderExecutionError with a provider_id when set. Configuration mistakes raise ProviderConfigurationError before the run starts.
See Provider configuration for model params and retry behavior.
Remote server mode (optional)
To target arcflow-server instead of the in-process runtime:
See Server API quickstart and Integrating track.
Common errors
| Exception | Typical cause |
|---|---|
WorkflowConfigurationError | Empty workflow name, no steps, invalid step() argument |
WorkflowExecutionError | Step failed at runtime; inspect run_id / failed_step on the exception |
TraceNotFoundError | trace() called before run() or run evicted from store |
Messages use the format [ArcFlow] <what happened>. <what to do>.
Verify
| Check | Expected |
|---|---|
| Import succeeds | import ok |
| Default run (no API key) | step_count == 2, non-empty output |
workflow.trace() after run | Summary prints without exception |
| Server mode (optional) | Same output shape when stack is up |
Next
| Topic | Link |
|---|---|
| Guided first workflow with verification | Track A: First workflow |
| Linear workflow design | Linear workflows |
| Provider configuration detail | Provider configuration |
| Execution traces | Execution traces |
| TypeScript twin | TypeScript quickstart |
| Server HTTP detail | Server API quickstart |