Skip to main content

Python SDK for DuraGraph - Reliable AI Workflow Orchestration

Project description

DuraGraph Python SDK

CI PyPI version Python versions Downloads License GitHub Stars

Python SDK for DuraGraph - Reliable AI Workflow Orchestration.

Build AI agents with decorators, deploy to a control plane, and get full observability out of the box.

Installation

The package is published as duragraph on PyPI (renamed from duragraph-python in v0.3.0; the old name is frozen at 0.2.1 and will not receive further releases). We recommend uv for dependency management.

# With uv (recommended)
uv add duragraph
uv add 'duragraph[openai]'
uv add 'duragraph[anthropic]'
uv add 'duragraph[all]'

# With pip
pip install duragraph

Quick Start

from duragraph import Graph, llm_node, entrypoint

@Graph(id="customer_support")
class CustomerSupportAgent:
    """A customer support agent that classifies and responds to queries."""

    @entrypoint
    @llm_node(model="gpt-4o-mini")
    def classify(self, state):
        """Classify the customer intent."""
        return {"intent": "billing"}

    @llm_node(model="gpt-4o-mini")
    def respond(self, state):
        """Generate a response based on intent."""
        return {"response": f"I'll help you with {state['intent']}."}

    # Define flow
    classify >> respond


# Run locally
agent = CustomerSupportAgent()
result = agent.run({"message": "I have a billing question"})
print(result)

# Or deploy to control plane
agent.serve("http://localhost:8081")

Features

Decorator-Based Graph Definition

from duragraph import Graph, llm_node, tool_node, router_node, human_node

@Graph(id="my_agent")
class MyAgent:
    @llm_node(model="gpt-4o-mini", temperature=0.7)
    def process(self, state):
        return state

    @tool_node
    def search(self, state):
        results = my_search_function(state["query"])
        return {"results": results}

    @router_node
    def route(self, state):
        return "path_a" if state["condition"] else "path_b"

    @human_node(prompt="Please review")
    def review(self, state):
        return state

Streaming

async for event in agent.stream({"message": "Hello"}):
    if event.type == "token":
        print(event.data, end="")
    elif event.type == "node_completed":
        print(f"\nNode {event.node_id} completed")

Subgraphs

@Graph(id="research")
class ResearchAgent:
    @llm_node
    def research(self, state):
        return {"findings": "..."}

@Graph(id="main")
class MainAgent:
    research = ResearchAgent.as_subgraph()

    @entrypoint
    def plan(self, state):
        return state

    plan >> research

Requirements

  • Python 3.10+
  • DuraGraph Control Plane (for deployment)

Documentation

Related modules

The Python SDK lives in the duragraph monorepo alongside its siblings:

Path Description
/ Core engine (Go, embeds dashboard + Studio)
go-sdk/ Go SDK
examples/ Example projects (multi-language)
docs/ Documentation site source
studio/ Visual workflow editor

Contributing

See CONTRIBUTING.md for guidelines.

License

Apache 2.0 - See LICENSE for details.

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

duragraph-0.3.2.tar.gz (325.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

duragraph-0.3.2-py3-none-any.whl (82.2 kB view details)

Uploaded Python 3

File details

Details for the file duragraph-0.3.2.tar.gz.

File metadata

  • Download URL: duragraph-0.3.2.tar.gz
  • Upload date:
  • Size: 325.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for duragraph-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6679267ce1ef7d4b43be481518a8cde745de7e6fed8f7c17026ad6bbfa746023
MD5 6044354b16bd36cbca964ac68968fc84
BLAKE2b-256 a621372561e93a0e71f0d1b6b6cf1aad710abec3c51ca66139643f88ac8b8433

See more details on using hashes here.

Provenance

The following attestation bundles were made for duragraph-0.3.2.tar.gz:

Publisher: pypi.yml on Duragraph/duragraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file duragraph-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: duragraph-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 82.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for duragraph-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5e2c7ffcb21b2c4e21ff9165484af8fbb3d5d05ddbb9a2a5789d070a829917
MD5 d837d3e9babfebfde36577d4ce564d20
BLAKE2b-256 1c90416f20211149526f1d42100f43e655f12d48b07456fdabc0f53ee336bf3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for duragraph-0.3.2-py3-none-any.whl:

Publisher: pypi.yml on Duragraph/duragraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page