Skip to content

Install the SDK

  • Python 3.9 or higher
  • pip (or any PEP 517 installer)
Terminal window
pip install systemr

The package installs one dependency: httpx for HTTP requests.

from systemr import SystemRClient

For error handling:

from systemr import (
SystemRClient,
SystemRError,
InsufficientBalanceError,
AuthenticationError,
)
client = SystemRClient(api_key="sr_agent_...")
ParameterTypeDefaultDescription
api_keystrRequiredYour agent API key (starts with sr_agent_).
base_urlstrhttps://agents.systemr.aiAPI base URL. Override for local development.
timeoutfloat30.0Request timeout in seconds.

For local development or self-hosted deployments:

client = SystemRClient(
api_key="sr_agent_...",
base_url="http://localhost:8000",
)

The client supports Python’s context manager protocol for automatic cleanup:

with SystemRClient(api_key="sr_agent_...") as client:
result = client.pre_trade_gate(
symbol="AAPL",
direction="long",
entry_price="185.50",
stop_price="180.00",
equity="100000",
)
print(result)
# HTTP connection is closed automatically

Or close manually:

client = SystemRClient(api_key="sr_agent_...")
# ... use client ...
client.close()
from systemr import SystemRClient, InsufficientBalanceError, AuthenticationError, SystemRError
client = SystemRClient(api_key="sr_agent_...")
try:
result = client.pre_trade_gate(
symbol="AAPL",
direction="long",
entry_price="185.50",
stop_price="180.00",
equity="100000",
)
except AuthenticationError:
print("Invalid API key or agent is not active")
except InsufficientBalanceError:
print("Deposit compute credits to continue")
except SystemRError as e:
print(f"API error ({e.status_code}): {e.detail}")
ExceptionHTTP StatusMeaning
AuthenticationError401Invalid or missing API key.
AuthenticationError403Agent is suspended or terminated.
InsufficientBalanceError402Compute credit balance too low.
SystemRError4xx/5xxAll other API errors.

You do not need the SDK. Any HTTP client works:

import httpx
resp = httpx.post(
"https://agents.systemr.ai/v1/tools/call",
headers={"X-API-Key": "sr_agent_..."},
json={
"tool_name": "calculate_position_size",
"arguments": {
"equity": "100000",
"entry_price": "185.50",
"stop_price": "180.00",
"direction": "long",
},
},
)
print(resp.json())
Terminal window
curl -X POST https://agents.systemr.ai/v1/tools/call \
-H "X-API-Key: sr_agent_..." \
-H "Content-Type: application/json" \
-d '{
"tool_name": "calculate_position_size",
"arguments": {
"equity": "100000",
"entry_price": "185.50",
"stop_price": "180.00",
"direction": "long"
}
}'

Every authenticated request requires the X-API-Key header:

X-API-Key: sr_agent_abc123def456...

The SDK handles this automatically. If you use raw HTTP, include the header in every request.

Public endpoints (no auth required):

  • GET /v1/billing/pricing
  • GET /v1/tools/list
  • GET /v1/guardian/status
  • GET /v1/broker/supported