Skip to main content

orchagent-python (SDK)

Python SDK for the Orchagent API: auth, threads, runs, SSE, approvals, and a simple chat helper.

Install (dev)

python -m venv .venv && source .venv/bin/activate
pip install -U pip wheel
pip install -e .

Quickstart

from orchagent import OrchClient

client = OrchClient(base_url="http://localhost:8080")
client.auth.login(email="you@example.com", password="pass123", save=True)

# Create a thread from a workflow JSON file
tid = client.threads.create_from_file("example_workflows/composio_calendar_hil_chat.json")

# Start a run
run = client.runs.send_message(tid, user_prompt="Hi", secrets={
    "providers": {"openai": {"api_key": "sk-..."}}
})

# Stream events
for evt in client.runs.stream_events(run["run_id"]):
    print(evt["type"], evt.get("message"))

See examples/ for more.

Configuration

  • Base URL: set ORCHAGENT_BASE_URL or pass base_url to OrchClient.
  • Token file: defaults to ~/.orchagent/token.json (0600 perms). You can override via ORCHAGENT_TOKEN_FILE.
  • Timeout: ORCHAGENT_TIMEOUT (seconds), default 30.

SDK Surface

  • client.auth.register(email, password, profile?, save=True) -> token
  • client.auth.login(email, password, save=True) -> token
  • client.auth.set_token(token, save=True) / client.auth.get_token()
  • client.threads.create(spec: dict) -> thread_id
  • client.threads.create_from_file(path: str) -> thread_id
  • client.threads.set_secrets(thread_id, secrets: dict) -> None
  • client.threads.history(thread_id, limit=20) -> Iterable[HistoryItem]
  • client.runs.send_message(thread_id, user_prompt, inputs?, secrets?) -> {run_id}
  • client.runs.stream_events(run_id) -> Iterable[dict] (SSE replay + live)
  • client.runs.resume(run_id) -> dict
  • client.approvals.approve(run_id, tool, server="mcp", args_keys=list[str]) -> dict
  • client.approvals.clear(all=False, user_id=None) -> dict
  • orchagent.chat.ChatSession(client, thread_id).ask(prompt, inputs?, secrets?) -> Iterable[dict]

Secrets & Precedence

The server merges secrets with this override order (highest to lowest):

  1. Run-time secrets: body.secrets in POST /threads/{id}/messages
  2. Thread secrets: POST /threads/{id}/secrets
  3. Workflow secrets: secrets in the workflow JSON
  4. Environment variables (e.g., OPENAI_API_KEY)

Placeholders like {{providers.openai.api_key}}, {{OPENAI_API_KEY}}, and {{inputs.user_id}} resolve from the merged secrets first, then env.

Provider examples (pass as secrets arg):

  • OpenAI standard
{"providers": {"openai": {"api_key": "sk-..."}}}
  • OpenAI-compatible (custom base_url)
{"providers": {"openai": {"api_key": "sk-...", "base_url": "https://compatible.example/api"}}}
  • Anthropic
{"providers": {"anthropic": {"api_key": "sk-ant-..."}}}
  • Gemini (Google GenAI)
{"providers": {"google_genai": {"api_key": "AIza..."}}}
  • Ollama (local)
{"providers": {"ollama": {"base_url": "http://localhost:11434"}}}
  • Tavily (MCP key used in URLs)
{"TAVILY_API_KEY": "tvly-...", "providers": {"openai": {"api_key": "sk-..."}}}

HIL (Auth Required) Flows

When the API emits auth.required, the event contains instruction and a redirect_url. Use client.runs.resume(run_id) after the user completes OAuth. The CLI handles this interactively; the SDK surfaces the event so you can implement your own prompt/UX.

Metadata

Release files for orchagent 0.1.3

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

Source distribution (sdist)

Source distribution for orchagent 0.1.3
File Size Uploaded
orchagent-0.1.3.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for orchagent 0.1.3
File Interpreter ABI Platform
orchagent-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / orchagent-0.1.3.tar.gz

Download URL orchagent-0.1.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
10e60b0f6e9bd12fc3264ce939f4653c00a30801fd1a3d076e1c830fd1a77f77
BLAKE2b-256 checksum
How to use checksums
0e0792bc17c9d6953115b8a372ce5dcb9832e1609144022e8c3db12d52e16e90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / orchagent-0.1.3-py3-none-any.whl

Download URL orchagent-0.1.3-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1513fa9882fcd8c7d4a32d8514bd0b90f6f4779aadaff6ed23d8f8b97debdaf
BLAKE2b-256 checksum
How to use checksums
4f96e0c13807fa3c27c62ce541d9fa97cb963a1b48accc57e8145f4213d67445
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

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