Skip to main content

argentor-sdk v1.4.7

Python SDK client for the Argentor AI agent framework REST API.

Installation

pip install argentor-sdk

For development:

pip install argentor-sdk[dev]

Quick Start

from argentor import ArgentorClient

client = ArgentorClient(
    base_url="http://localhost:8080",
    api_key="your-api-key",
)

# Run a task
result = client.run_task(
    role="code_reviewer",
    context="Review the following pull request...",
)
print(result)

# Stream results via SSE
for chunk in client.run_task_stream(
    role="assistant",
    context="Explain how Argentor works",
):
    print(chunk, end="", flush=True)

# Batch execution
batch = client.batch_tasks(
    tasks=[
        {"agent_role": "analyst", "context": "Analyze Q1 sales data"},
        {"agent_role": "analyst", "context": "Analyze Q2 sales data"},
    ],
    max_concurrent=5,
)
print(batch)

# Evaluate a response
evaluation = client.evaluate(
    text="The code looks clean and follows best practices.",
    context="Code review task",
    criteria=["accuracy", "completeness", "helpfulness"],
)
print(evaluation)

# List skills
skills = client.list_skills()
for skill in skills:
    print(skill["name"])

# Execute a skill
result = client.execute_skill("echo", {"text": "Hello, world!"})
print(result)

# Health check
health = client.health()
print(health)

Async Usage

import asyncio
from argentor import AsyncArgentorClient

async def main():
    async with AsyncArgentorClient(
        base_url="http://localhost:8080",
        api_key="your-api-key",
    ) as client:
        # Run a task
        result = await client.run_task(
            role="assistant",
            context="Hello, world!",
        )
        print(result)

        # Stream results
        async for chunk in client.run_task_stream(
            role="assistant",
            context="Explain Argentor",
        ):
            print(chunk)

        # List sessions
        sessions = await client.list_sessions()
        print(sessions)

asyncio.run(main())

Agent SDK (subprocess wrapper)

The agent module wraps the argentor CLI binary as a subprocess, similar to how Claude Agent SDK wraps Claude Code. It communicates via NDJSON over stdin/stdout and works with any LLM provider.

import asyncio
from argentor import query, query_simple, AgentOptions

# Stream events from the agent
async def main():
    async for event in query(
        "What files are in this directory?",
        AgentOptions.claude("sk-your-api-key"),
    ):
        if event.type == "assistant":
            print(event.text)
        elif event.type == "tool_use":
            print(f"[tool] {event.data.get('name')}")
        elif event.is_done:
            print(f"\nDone: {event.text}")

asyncio.run(main())

One-liner convenience functions

from argentor import ask_claude, ask_openai, ask_gemini, ask_ollama

# Each returns the final text output
result = asyncio.run(ask_claude("Explain Argentor", "sk-..."))
result = asyncio.run(ask_openai("Explain Argentor", "sk-..."))
result = asyncio.run(ask_gemini("Explain Argentor", "AIza..."))
result = asyncio.run(ask_ollama("Explain Argentor", "llama3"))

Provider presets

AgentOptions.claude(api_key)   # Anthropic Claude
AgentOptions.openai(api_key)   # OpenAI GPT-4o
AgentOptions.gemini(api_key)   # Google Gemini
AgentOptions.ollama("llama3")  # Local Ollama (no key)

AgentOptions

Parameter Type Default Description
provider str "claude" LLM provider
model str "claude-sonnet-4-20250514" Model name
api_key str "" API key
system_prompt str|None None System prompt override
max_turns int 10 Max agentic turns
temperature float 0.7 Sampling temperature
tools list[str]|None None Tool names (None = builtins)
permission_mode str "default" "default", "strict", "permissive", "plan"
working_directory str|None None Working directory
mcp_servers list[dict]|None None MCP server configs
argentor_binary str|None None Path to binary (auto-detected if omitted)

Error Handling

from argentor import ArgentorClient
from argentor.exceptions import ArgentorAPIError, ArgentorConnectionError

client = ArgentorClient(base_url="http://localhost:8080")

try:
    result = client.run_task(role="assistant", context="Hello")
except ArgentorAPIError as e:
    print(f"API error {e.status_code}: {e.message}")
    print(f"Response body: {e.response_body}")
except ArgentorConnectionError as e:
    print(f"Connection failed: {e.message}")

API Reference

ArgentorClient / AsyncArgentorClient

Both clients expose the same methods. The async client returns awaitables and uses async for for streaming.

Method Description
run_task(role, context, **kwargs) Execute a single agent task
run_task_stream(role, context, **kwargs) Stream task results via SSE
batch_tasks(tasks, max_concurrent=5) Submit a batch of tasks
evaluate(text, context, criteria) Evaluate text against criteria
agent_chat(message, **kwargs) Send a message via agent chat
agent_status() Get agent status
create_session() Create a new session
get_session(session_id) Retrieve a session
list_sessions() List all sessions
delete_session(session_id) Delete a session
list_skills() List registered skills
get_skill(name) Get skill details
execute_skill(name, arguments) Execute a skill
health() Check API health
health_ready() Readiness probe
metrics() Get Prometheus metrics
list_connections() List WebSocket connections
create_persona(tenant_id, agent_role, persona) Create persona
list_personas(tenant_id) List tenant personas
get_usage(tenant_id) Get usage breakdown
webhook_proxy(event, data, **kwargs) Forward a webhook
search_marketplace(query, category) Search skill marketplace
install_skill(name) Install from marketplace

License

AGPL-3.0-only

Metadata

Release files for argentor-sdk 1.5.0

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

Source distribution (sdist)

Source distribution for argentor-sdk 1.5.0
File Size Uploaded Provenance
argentor_sdk-1.5.0.tar.gz 26.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for argentor-sdk 1.5.0
File Interpreter ABI Platform
argentor_sdk-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.4 kB

Release files / argentor_sdk-1.5.0.tar.gz

Download URL argentor_sdk-1.5.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
828e7e915613420ddf9d180a829875c87b5edb7efdd04f81702f8e5430c89022
BLAKE2b-256 checksum
How to use checksums
b956360e456a6c7dbd9947f250285f27302cd264d809a8b0070ac8d17964f506
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / argentor_sdk-1.5.0-py3-none-any.whl

Download URL argentor_sdk-1.5.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0d6c8a50c38d6f24f91cf0031754853437a51cf20da3f8cf170a4e8414d4fda
BLAKE2b-256 checksum
How to use checksums
120abe1b146db732ca349db5ded466f1b55dbd8bf58a79d188aad9fac2621c97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for argentor-sdk 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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