Skip to main content

Production Python SDK for the Managed Agent API

Project description

Python SDK

Production Python SDK for the Managed Agent API.

Install

pip install cloudsway-agent

For local development from this repository:

cd sdk/python
pip install -e .

Quick start

from agent_api import AgentAPI

client = AgentAPI(
    api_key="sk-...",
    base_url="https://api.agentsway.dev",
)

response = client.responses.create(
    preset="pro-search",
    input="What changed in AI this week?",
)
print(response["output_text"])
client.close()

Environment variables AGENT_API_KEY and AGENT_API_BASE_URL are used by default. The default base URL is https://api.agentsway.dev when neither argument nor env is set. AsyncAgentAPI is available for async integrations.

Package layout

src/agent_api/
  client.py            # synchronous AgentAPI
  async_client.py      # AsyncAgentAPI
  errors.py            # typed exceptions
  pagination.py          # cursor pagination
  streaming.py           # SSE parser
  _http.py               # retries, timeouts, User-Agent
  resources/             # responses, models, presets, tools
  types/                 # TypedDict contracts

Resources

Resource Methods
client.responses / client.agent create, list, list_page, list_iterator, retrieve, cancel, list_children, list_events
client.models list
client.presets list
client.tools list

Production features

  • Retries: exponential backoff for network failures, 429, and 5xx (default 2 retries).
  • Timeouts: 10 minute default; 1 hour for streaming (override with timeout / stream_timeout).
  • Typed errors: AuthenticationError, RateLimitError, NotFoundError, etc.
  • Pagination: list_page() and list_iterator() for cursor-based history.
for item in client.responses.list_iterator(limit=20):
    print(item["id"], item["status"])

Streaming

for event in client.responses.create(
    preset="fast-search",
    input="Summarize today's AI news.",
    stream=True,
):
    if event["type"] == "response.output_text.delta":
        print(event.get("delta", ""), end="")

Client options

client = AgentAPI(
    api_key="sk-...",
    base_url="https://api.agentsway.dev",
    timeout=600.0,
    stream_timeout=3600.0,
    max_retries=2,
)

Tests

PYTHONPATH=src python -m unittest discover -s tests -p 'test_agent_api.py' -v
AGENT_API_INTEGRATION=1 AGENT_API_KEY=sk-... AGENT_API_BASE_URL=https://api.agentsway.dev \
  PYTHONPATH=src python -m unittest tests.test_integration -v

Scope

The SDK covers the public agent/Responses API and discovery endpoints. Console auth, workspace administration, and internal audit records are intentionally out of scope.

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

cloudsway_agent-1.0.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

cloudsway_agent-1.0.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file cloudsway_agent-1.0.0.tar.gz.

File metadata

  • Download URL: cloudsway_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cloudsway_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fadcb8ec61d982dc5f568ba408117af047d6522de4996962719896fbbd7e10b5
MD5 3881915edb7c090adb1acf8e442288c4
BLAKE2b-256 d695220db26f82f2a72a4d4d3f742799977a4697431428583d02011409a9f08c

See more details on using hashes here.

File details

Details for the file cloudsway_agent-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudsway_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57d352f0fa2f2aded5b519681e48caf55563c2e5923242acfcd42a3191ba7726
MD5 10016f080def480ad86e940e824e1b4c
BLAKE2b-256 05f594d66cfc71a0ba2d64545c0929987fbb67fa6323ed4c782600a5fab4a421

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