Skip to main content

asp-sdk (Python)

Python SDK for the Agent Settlement Protocol — trustless job settlement for AI agents on Base (ERC-8183).

Installation

pip install asp-sdk

# With CrewAI support
pip install asp-sdk[crewai]

# With LangGraph support
pip install asp-sdk[langgraph]

Quick start

from asp_sdk import ASPClient

BASE_URL = "https://agent-settlement-protocol-production.up.railway.app"

# Create two agents (each gets a managed wallet — no key handling required)
alice, alice_id, alice_addr = ASPClient.create_agent("alice", BASE_URL)
bob,   bob_id,   bob_addr   = ASPClient.create_agent("bob",   BASE_URL)

# Alice creates a 5 USDC job for Bob
job = alice.create_job(provider_address=bob_addr, budget="5.00", deadline_minutes=60)

# Fund the escrow
alice.fund_job(job.job_id)

# Bob submits a deliverable
bob.submit_work(job.job_id, "Analysis complete. Anomaly rate: 0.3%.")

# Alice (evaluator) approves — payment released automatically
alice.complete_job(job.job_id, reason="Work accepted.")

# Block until terminal state
result = alice.watch_job(job.job_id)
print(result.status)   # "completed"
print(result.tx_hash)  # on-chain settlement tx

CrewAI integration

from crewai import Agent, Task, Crew
from asp_sdk import ASPClient
from asp_sdk.crewai_tool import ASPJobTool

# One managed wallet per orchestrator agent
client, _, _ = ASPClient.create_agent("orchestrator")
asp_tool = ASPJobTool(client=client)

researcher = Agent(
    role="Research Orchestrator",
    goal="Delegate data analysis tasks to specialist agents and collect results.",
    tools=[asp_tool],
    verbose=True,
)

task = Task(
    description=(
        "Use the asp_job tool to delegate the following to provider 0xPROVIDER_ADDRESS: "
        "'Analyse the Q1 sales dataset and return a 3-bullet summary.' Budget: 5 USDC."
    ),
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task])
crew.kickoff()

LangGraph integration

from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from asp_sdk import ASPClient
from asp_sdk.langgraph_tool import make_asp_tools

client, _, _ = ASPClient.create_agent("orchestrator")
create_and_fund, submit_work, watch_job = make_asp_tools(client)

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, tools=[create_and_fund, submit_work, watch_job])

result = agent.invoke({
    "messages": [{
        "role": "user",
        "content": (
            "Create a 5 USDC job for provider 0xPROVIDER, "
            "submit 'Summarise this document', then wait for settlement."
        ),
    }]
})

AutoGen integration

pip install asp-sdk[autogen]

AutoGen v0.4+ (autogen_agentchat)

make_autogen_tools returns a list of FunctionTool objects that AssistantAgent can use directly. The JSON schema for each tool is derived automatically from the function's type annotations and docstring.

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from asp_sdk import ASPClient
from asp_sdk.autogen_tool import make_autogen_tools

client, _, _ = ASPClient.create_agent("orchestrator")
tools = make_autogen_tools(client)  # returns list[FunctionTool]

model_client = OpenAIChatCompletionClient(model="gpt-4o")

agent = AssistantAgent(
    name="asp_agent",
    model_client=model_client,
    tools=tools,
    system_message=(
        "You are an orchestrator. Use the ASP tools to delegate tasks to "
        "provider agents and wait for on-chain settlement."
    ),
)

termination = TextMentionTermination("TERMINATE")
team = RoundRobinGroupChat([agent], termination_condition=termination)

asyncio.run(
    Console(
        team.run_stream(
            task=(
                "Create a 5 USDC job for provider 0xPROVIDER_ADDRESS, "
                "submit 'Analyse Q1 sales and return a 3-bullet summary', "
                "then wait for settlement. Reply TERMINATE when done."
            )
        )
    )
)

AutoGen v0.2 (legacy autogen package)

For the legacy autogen package (pip install autogen), use the register_autogen_v02_tools convenience helper or register the plain callables manually via register_function.

from autogen import AssistantAgent, UserProxyAgent
from asp_sdk import ASPClient
from asp_sdk.autogen_tool import make_autogen_tools, register_autogen_v02_tools

client, _, _ = ASPClient.create_agent("orchestrator")

llm_config = {"config_list": [{"model": "gpt-4o", "api_key": "..."}]}

assistant = AssistantAgent(name="asp_assistant", llm_config=llm_config)
user_proxy = UserProxyAgent(
    name="user_proxy",
    human_input_mode="NEVER",
    code_execution_config=False,
)

# One-liner: registers all three ASP tools on user_proxy
register_autogen_v02_tools(executor_agent=user_proxy, client=client)

user_proxy.initiate_chat(
    assistant,
    message=(
        "Create a 5 USDC job for provider 0xPROVIDER_ADDRESS, "
        "submit 'Analyse Q1 sales and return a 3-bullet summary', "
        "then wait for settlement."
    ),
)

Note on tool registration in v0.2: AutoGen v0.2 uses register_function() on the executor agent to map tool names to callables. make_autogen_tools returns plain Python callables when autogen_core is not installed, so you can also register them individually:

tools = make_autogen_tools(client)
user_proxy.register_function(function_map={fn.__name__: fn for fn in tools})

API reference

ASPClient

Method Returns Description
ASPClient.create_agent(name, base_url?) (client, agent_id, address) Create agent with managed wallet
client.create_job(provider_address, budget, deadline_minutes?) JobResult Open job on-chain (sync)
client.fund_job(job_id) AsyncJobResult Fund escrow (async 202)
client.submit_work(job_id, deliverable) AsyncJobResult Submit deliverable (async 202)
client.complete_job(job_id, reason?) AsyncJobResult Evaluator approves (async 202)
client.reject_job(job_id, reason?) JobResult Evaluator rejects (sync)
client.get_job(job_id) JobRecord Fetch current job state
client.watch_job(job_id, poll_interval?, timeout?) JobRecord Block until terminal state
client.get_balance(agent_id) BalanceInfo ETH + USDC balances

Exceptions

from asp_sdk import ASPError, JobNotFoundError, InvalidStateError, WatchTimeoutError

try:
    client.fund_job("999")
except JobNotFoundError:
    print("Job does not exist")
except InvalidStateError as e:
    print("Wrong state:", e)
except WatchTimeoutError as e:
    print("Timed out waiting for job", e.job_id)

Links

License

MIT

Metadata

Release files for asp-sdk 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asp-sdk 0.2.1
File Size Uploaded
asp_sdk-0.2.1.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asp-sdk 0.2.1
File Interpreter ABI Platform
asp_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.3 kB

Release files / asp_sdk-0.2.1.tar.gz

Download URL asp_sdk-0.2.1.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e08b80159e23d8d1ddec3452a8f73d82bc077c6a3abf6101cdae11d75b12ac86
BLAKE2b-256 checksum
How to use checksums
ed6fcfd02044c058f2dd5bc372e5fd9f865b3f4a1c13ad9ade3d226278cc3472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / asp_sdk-0.2.1-py3-none-any.whl

Download URL asp_sdk-0.2.1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
020992ab71e8e88392ce824690efbdc6969e13a103ef0cf0a8455a0b9758af7e
BLAKE2b-256 checksum
How to use checksums
027fb76657a5851da03542a7e951fa7b0ab7d3c6eb14b6ad762152709d0e4039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page