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_URLor passbase_urltoOrchClient. - Token file: defaults to
~/.orchagent/token.json(0600 perms). You can override viaORCHAGENT_TOKEN_FILE. - Timeout:
ORCHAGENT_TIMEOUT(seconds), default 30.
SDK Surface
client.auth.register(email, password, profile?, save=True) -> tokenclient.auth.login(email, password, save=True) -> tokenclient.auth.set_token(token, save=True)/client.auth.get_token()client.threads.create(spec: dict) -> thread_idclient.threads.create_from_file(path: str) -> thread_idclient.threads.set_secrets(thread_id, secrets: dict) -> Noneclient.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) -> dictclient.approvals.approve(run_id, tool, server="mcp", args_keys=list[str]) -> dictclient.approvals.clear(all=False, user_id=None) -> dictorchagent.chat.ChatSession(client, thread_id).ask(prompt, inputs?, secrets?) -> Iterable[dict]
Secrets & Precedence
The server merges secrets with this override order (highest to lowest):
- Run-time secrets: body.secrets in
POST /threads/{id}/messages - Thread secrets:
POST /threads/{id}/secrets - Workflow secrets:
secretsin the workflow JSON - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e60b0f6e9bd12fc3264ce939f4653c00a30801fd1a3d076e1c830fd1a77f77
|
|
| MD5 |
2f5a7d180797da2154f97fa3d4354c47
|
|
| BLAKE2b-256 |
0e0792bc17c9d6953115b8a372ce5dcb9832e1609144022e8c3db12d52e16e90
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1513fa9882fcd8c7d4a32d8514bd0b90f6f4779aadaff6ed23d8f8b97debdaf
|
|
| MD5 |
c4a9aff79bab0fcf1699daf5a80bb75c
|
|
| BLAKE2b-256 |
4f96e0c13807fa3c27c62ce541d9fa97cb963a1b48accc57e8145f4213d67445
|