Skip to main content

SecureSpace SDK for Python

Send your agent's calls to outside services through the SecureSpace Gateway. Each call is checked against your organization's rules, and blocked calls come back as a value you can handle, never a silent failure. Standard library only.

You need a SecureSpace account and an agent key: sign up at https://securespace.club, then create an agent in the console.

pip install securespace
import os
from securespace import SecureSpaceClient

client = SecureSpaceClient("https://gateway.securespace.club", os.environ["SECURESPACE_API_KEY"])

# "crm" is a service registered on the console's Upstreams page.
res = client.get("crm", "/contacts")
if res.blocked:
    print("blocked:", res.error_code)
else:
    print(res.body)

Guard your agent's tools

Wrap a tool so SecureSpace decides before it runs. It works with any framework that builds tools from plain functions (OpenAI Agents SDK, LangChain, LangGraph, CrewAI, LlamaIndex), sync or async. Put it under the framework's own decorator, so the framework still sees the function's arguments and docstring.

import os

from agents import function_tool  # or langchain's @tool, crewai's @tool, ...
from securespace import Guard, SecureSpaceToolBlocked

guard = Guard(
    "https://gateway.securespace.club",
    os.environ["SECURESPACE_API_KEY"],
    namespace="billing",          # rules match this as the destination
)

@function_tool
@guard.tool(declared_verb="transfer")
def refund(order_id: str, amount: int) -> str:
    """Refund an order."""
    ...

A refused call raises SecureSpaceToolBlocked instead of running. Frameworks can hand that to the model as a tool error, so the agent learns it was not allowed (the OpenAI Agents SDK does by default; in LangChain set handle_tool_error=True). When a rule needs approval, the message names the request; once a person approves, the identical call runs once. Only a hash of the arguments is sent, never the arguments.

Send chosen hosts through the Gateway

Route only the hosts you list through the Gateway; everything else goes out untouched, and your SecureSpace key is never sent to it.

import os

import httpx, requests
from securespace import AddressedRoutes

routes = AddressedRoutes(
    "https://gateway.securespace.club",
    os.environ["SECURESPACE_API_KEY"],
    {"api.stripe.com": "stripe"},  # host -> name registered on the Upstreams page
)

client = httpx.Client(transport=routes.httpx_transport())         # httpx
aclient = httpx.AsyncClient(transport=routes.httpx_async_transport())
session = routes.mount_requests(requests.Session())               # requests

Neither httpx nor requests is required by the SDK; use whichever you have.

Requires Python 3.9 or later.

Metadata

Release files for securespace 0.2.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 securespace 0.2.0
File Size Uploaded Provenance Actions
securespace-0.2.0.tar.gz 10.5 kB Without provenance Details for securespace-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 22.4 kB

Release files / securespace-0.2.0.tar.gz

Download URL securespace-0.2.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
793aef58bd807171c44a202a6d08ea6c8843bd3a8f513aa2bd02225dfb6f3145
BLAKE2b-256 checksum
How to use checksums
a1b965aa12cd3231af4c7f8cb02bc076345566fb1788307a6b973b0ce2e9458c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / securespace-0.2.0-py3-none-any.whl

Download URL securespace-0.2.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd75131ba8a5d0b010063d045d85e5903d3304c448ada76ed5e05e67e008a499
BLAKE2b-256 checksum
How to use checksums
0dd9f4ab8a4637a6b3b193a84e80e95be903c8663ef4e0b43ec1c9d9b0388594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for securespace 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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