SYSTEM R AI

Install the SDK

Install the Python SDK and configure your client.

Requirements

  • Python 3.9 or higher
  • pip (or any PEP 517 installer)

Install

pip install systemr

The package installs one dependency: httpx for HTTP requests.

Import

from systemr import SystemRClient

For error handling:

from systemr import (
    SystemRClient,
    SystemRError,
    InsufficientBalanceError,
    AuthenticationError,
)

Initialize the client

client = SystemRClient(api_key="sr_agent_...")

Constructor parameters

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.

Custom base URL

For local development or self-hosted deployments:

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

Context manager

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()

Error handling

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}")

Error types

ExceptionHTTP StatusMeaning
AuthenticationError401Invalid or missing API key.
AuthenticationError403Agent is suspended or terminated.
InsufficientBalanceError402Compute credit balance too low.
SystemRError4xx/5xxAll other API errors.

Using raw REST calls

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())
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"
    }
  }'

Authentication

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
System R AI
Python SDKpip install systemr
MCP Serveragents.systemr.ai/mcp/sse
OpenAPI Specagents.systemr.ai/openapi.json
Machine Docsagents.systemr.ai/llms.txt
GitHubSystem-R-AI
X@Systemrai
YouTube@systemr_ai
Emailhello@systemr.ai
Phone628 333 6693
Address7901 4TH ST N, STE 28529, ST PETERSBURG, FL 33702
TermsTerms of Service
PrivacyPrivacy Policy
SecuritySecurity Policy
© 2026 System R AI. Software platform. Not financial advice.

On this page