Skip to main content

Python SDK for the Orchagent API

Project description

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.

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

orchagent-0.1.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

orchagent-0.1.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file orchagent-0.1.3.tar.gz.

File metadata

  • Download URL: orchagent-0.1.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for orchagent-0.1.3.tar.gz
Algorithm Hash digest
SHA256 10e60b0f6e9bd12fc3264ce939f4653c00a30801fd1a3d076e1c830fd1a77f77
MD5 2f5a7d180797da2154f97fa3d4354c47
BLAKE2b-256 0e0792bc17c9d6953115b8a372ce5dcb9832e1609144022e8c3db12d52e16e90

See more details on using hashes here.

File details

Details for the file orchagent-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: orchagent-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for orchagent-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a1513fa9882fcd8c7d4a32d8514bd0b90f6f4779aadaff6ed23d8f8b97debdaf
MD5 c4a9aff79bab0fcf1699daf5a80bb75c
BLAKE2b-256 4f96e0c13807fa3c27c62ce541d9fa97cb963a1b48accc57e8145f4213d67445

See more details on using hashes here.

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