Skip to main content

Official StewAI Python SDK

Project description

stewai (Python SDK)

PyPI version Python versions

Base URL (only): https://api.stewai.com/v1

Public docs:

  • SDK overview: https://docs.stewai.com/sdk-api/overview
  • Availability, scopes, and feature gates: https://docs.stewai.com/sdk-api/availability-and-access

Install

pip install -U stewai

Get an API key

  1. Log in to stewai.com
  2. Go to Settings → API keys
  3. Create a key and copy it once (sk-live-...)

Usage

from stewai import Client

client = Client(api_key="sk-live-...")

# Use the Input step “API input id” shown in the editor as the inputs key
run = client.runs.create(
    recipe_id="01K....",
    inputs={"USERQUESTION": "What should I focus on this week?"},
    wait="safe",
)

print(run.status)      # done|failed|cancelled|blocked
print(run.outputs())   # concrete output_flat primary values by step id

# Debug only: full execution trace (steps + outputs)
trace = client.runs.steps(run.run_id)

List runs

runs = client.runs.list(page=1, page_size=20, status="done")
print(runs["count"])

List own recipes (/v1/recipes/)

recipes = client.recipes.list(page=1, page_size=20)
print(recipes["count"])

client.recipes.get/create/update/delete map to server endpoints that are currently disabled by default and may return 404.

Recipe contracts (own published recipes)

contract = client.recipes.get_execution_contract("01K....")

print(contract["contract_version"])
print(contract["step_order"])
print(sorted(contract["steps"].keys()))
  • client.recipes.get_execution_contract(...) returns the full pre-execution contract for all step outputs in a published recipe.
  • client.recipes.get_output_contract(...) is narrower: it returns only the final recipe_output surface and may return recipe_output_missing when the recipe has no final output step.

Access and availability notes

  • client.runs is baseline public v1.
  • client.recipes.list() is baseline public v1.
  • client.recipes.get/create/update/delete exist in the SDK, but may return 404 when recipe self-service is disabled on the deployment.
  • client.recipes.get_execution_contract(...) and client.recipes.get_output_contract(...) use the same recipe self-service surface and require a published same-org recipe with recipes:read.
  • client.marketplace.* requires Marketplace to be enabled on the deployment.
  • client.marketplace.search(...) also requires the Marketplace search index.
  • client.marketplace.input_fields(...) needs marketplace:read; it is never called implicitly by marketplace.run(...).
  • client.marketplace.run(...) needs marketplace:run and still posts directly by default.
  • client.storage.* requires Storage to be enabled on the deployment.
  • Scoped keys need the matching permissions such as runs:create, runs:read, recipes:read, recipes:write, marketplace:read, and marketplace:run.

Marketplace discovery (query -> detail -> run)

from stewai import Client

client = Client(api_key="sk-live-...")

recipes = client.marketplace.search(
    "gemini web search",
    visibility="public_open",
    page=1,
    page_size=20,
)

first = recipes["results"][0]
detail = client.marketplace.detail(first["recipe_ulid"])

from stewai import validate_inputs

fields = client.marketplace.input_fields(first["recipe_ulid"])
inputs = {"query": "latest gemini model updates"}
validate_inputs(inputs, fields)

outcome = client.marketplace.run(
    first["recipe_ulid"],
    inputs=inputs,
    wait="safe",
)
print(outcome.status)

Ingest sources (URLs + Pantry docs)

from stewai import Client, IngestSource

client = Client(api_key="sk-live-...")

run = client.runs.create(
    recipe_id="01K....",
    ingest={
        "ingest_1": [
            IngestSource(uri="https://example.com/docs", kind="url"),
        ]
    },
)

Upload + resolve Pantry paths

from stewai import Client, IngestSource

client = Client(api_key="sk-live-...")

upload = client.storage.upload("./report.pdf")
run = client.runs.create(
    recipe_id="01K....",
    ingest={"ingest_1": [upload.to_ingest_source(label="Q4 Report")]},
)

resolved = client.storage.resolve_path("Reports/Q4.pdf")
if resolved:
    client.runs.create(
        recipe_id="01K....",
        ingest={"ingest_1": [resolved.to_ingest_source()]},
    )

Environment variable

export STEWAI_API_KEY="sk-live-..."
from stewai import Client

client = Client()  # reads STEWAI_API_KEY
run = client.runs.create(recipe_id="01K....", wait=False)
run = client.runs.wait(run["id"], timeout=300)

Output usage contract (credits-first)

  • client.runs.steps(run_id) returns output_flat.usage with credits-focused billing fields.
  • Raw token counters are hidden by default in user-facing v1 responses.
  • Compatibility mode for token counters is server-gated and requires privileged access.

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

stewai-0.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

stewai-0.2.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file stewai-0.2.0.tar.gz.

File metadata

  • Download URL: stewai-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stewai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 438e8f0e6ab65c863b0d1f9c8d4f1a7fb1d546f61875f9852d5ce2d96beb8357
MD5 de5c40ce118fe8d66a37807a238d1632
BLAKE2b-256 32ef0b706596cc9dd44f3356abf3db9d57e40878e699ad697092d879bf291f19

See more details on using hashes here.

Provenance

The following attestation bundles were made for stewai-0.2.0.tar.gz:

Publisher: pypi-stewai.yml on cmumulle/stewai-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stewai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: stewai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stewai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b959490da637c827af65f5fffeca6c2eb8ad60c3854459654aee3925c23f53
MD5 448b44f25708bd35dd56db15a32f1d9d
BLAKE2b-256 adc622631a75787c20e0e7fbd9865ebc509d39696d3219ec6f83293597d8affc

See more details on using hashes here.

Provenance

The following attestation bundles were made for stewai-0.2.0-py3-none-any.whl:

Publisher: pypi-stewai.yml on cmumulle/stewai-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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