The Python client for Sandbox AI. An agent proposes a change to a record in a business system, such as Salesforce or ServiceNow, and gets back what Sandbox AI decided for each field: applied, held for a person's approval, or blocked by a rule. Built on httpx and Pydantic. Python 3.11 and later.
Alpha. This is an early release, and the API may change before 1.0. It needs access to a Sandbox AI gateway: an agent key and the gateway's address.
pip install sandbox-ai-sdk Or uv add sandbox-ai-sdk. The import is sandbox_ai.
In the Sandbox AI dashboard, open Agents, add your agent and create a key. Copy it: you only see it once.
Give the client the key and your gateway's address, as arguments or as environment variables. Both are required:
export SANDBOX_AI_API_KEY=sbx_... export SANDBOX_AI_BASE_URL=https://your-gateway.example.com Propose a change:
from sandbox_ai import Client client = Client() # reads SANDBOX_AI_API_KEY and SANDBOX_AI_BASE_URL # or: Client(api_key="sbx_...", base_url="https://your-gateway.example.com") decision = client.propose_change( "salesforce", # system "account", # object "001-SAMPLE-0142", # record_id: None to create a record {"OwnerId": "005-SAMPLE-MARCUS"}, reason="Customer asked to work with Marcus", # shown to approvers ) if decision.status == "needs_approval": # A person decides. Check again later. decision = client.get_decision(decision.change_id) The key identifies the agent, so there's no agent id to pass. Use the client as a context manager (with Client(...) as client:) or call client.close() when done.
Each item in decision.fields has the field, before, after, the outcome (allow, needs_approval or blocked), the rule_ids that decided it, and whether it was written.
decision.message and decision.rule_ids say why for the change as a whole. A delete has no fields and is always blocked, in watch-only too, so those two are always set for one.
Everything raises SandboxAIError, with:
Every propose_change call sends an idempotency key: yours, or one the SDK makes. If the call times out waiting for an answer, the connection drops after sending, or the gateway answers with a 5xx or something the SDK can't read, the change may already have been made. Retry with the key from the error, within 24 hours, and the gateway returns the first decision instead of making the change twice:
from sandbox_ai import Client, SandboxAIError client = Client() try: decision = client.propose_change("salesforce", "account", None, {"Name": "Acme"}) except SandboxAIError as error: if not error.idempotency_key: raise decision = client.propose_change( "salesforce", "account", None, {"Name": "Acme"}, idempotency_key=error.idempotency_key ) The error's message names the key too, so it's there for an agent reading the text. If the connection never opened, such as a refused connection, a connection that timed out before it opened, or a wrong address, nothing was sent: idempotency_key is None and the message says to check the address. A 4xx means the gateway refused the request, so it's None then too.
Keys belong to the API key that sent them, so another agent's key never matches yours. get_decision only reads, so after a timeout there's no key to think about: just call it again.
The API key never appears in errors, logs or repr(client).
A blank or whitespace-only api_key or base_url argument counts as not given, so the client falls back to SANDBOX_AI_API_KEY or SANDBOX_AI_BASE_URL.
Apache-2.0. The full license text is in the LICENSE file included in the package.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
None of the files in this release were uploaded with provenance metadata.
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.
Nov 22, 2026 2 release files No provenance




