Skip to main content

stewrd

Python SDK for the Stewrd Agent API.

Install

pip install stewrd

Quickstart

from stewrd import Stewrd

stewrd = Stewrd("sk-stw_your_key")

result = stewrd.agent.run(
    message="Research the top 5 CRM tools",
    capabilities=["research", "documents"],
)

print(result.message)
print(result.files[0].url)

Streaming

for event in stewrd.agent.stream(message="Write a detailed analysis"):
    if event.type == "token":
        print(event.content, end="")
    if event.type == "tool_start":
        print(f"Using {event.tool}...")
    if event.type == "done":
        print(f"\n\nTokens: {event.usage.tokens_used}")

You can also collect the full response after streaming:

stream = stewrd.agent.stream(message="Hello")
response = stream.final_response()
print(response.message)

Configuration

stewrd = Stewrd(
    "sk-stw_...",
    base_url="https://api.stewrd.dev",  # default
    timeout=120.0,                       # default, in seconds
)

API Reference

Stewrd(api_key, *, base_url, timeout)

Create a new client instance.

Param Type Description
api_key str Your Stewrd API key (sk-stw_...)
base_url str API base URL (default: https://api.stewrd.dev)
timeout float Request timeout in seconds (default: 120.0)

stewrd.agent.run(message, *, capabilities, files)

Run the agent synchronously. Returns AgentResponse.

Param Type Description
message str The instruction for the agent
capabilities list[str] Capabilities to enable (e.g. ["research", "documents"])
files list[InputFile] Files to include as context

stewrd.agent.stream(message, *, capabilities, files)

Run the agent with streaming. Returns AgentStream.

Takes the same params as run(). The returned AgentStream is an Iterator[StreamEvent].

Stream Events

Event Fields Description
token content: str A chunk of response text
tool_start tool: str A tool invocation started
tool_end tool: str A tool invocation finished
done response, usage Stream complete with full response
error code: str, message: str An error occurred

StewrdError

Thrown on non-2xx API responses.

from stewrd import Stewrd, StewrdError

try:
    stewrd.agent.run(message="...")
except StewrdError as e:
    print(e.status)   # 401
    print(e.code)     # 'invalid_api_key'
    print(e.message)  # 'Invalid API key'
    print(e.docs)     # 'https://docs.stewrd.dev/errors/invalid_api_key'

Requirements

  • Python 3.9+
  • httpx (installed automatically)

License

MIT

Metadata

Release files for stewrd 1.1.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 stewrd 1.1.0
File Size Uploaded Provenance Actions
stewrd-1.1.0.tar.gz 7.1 kB Without provenance Details for stewrd-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 16.3 kB

Release files / stewrd-1.1.0.tar.gz

Download URL stewrd-1.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5337c9a8c94e5a36b91324cc8ea30801f37b3bacdb7bbdd9399a6b0a47ba35db
BLAKE2b-256 checksum
How to use checksums
72ca3e0491fe1495e50e24db1d5f3738d2cdcdbe8729747f41617fac99eace3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / stewrd-1.1.0-py3-none-any.whl

Download URL stewrd-1.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2683e0dc46443fe65612289875bd61508b960a322256650dfae8ceed29624e6
BLAKE2b-256 checksum
How to use checksums
2f87be6e9662c81e0b9312e88402eccebd28faa4aec575f195c5223afc7daddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for stewrd 1.1.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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