SDK Reference
Complete API reference for Sardis Python and TypeScript SDKs. Payments, wallets, policies, and framework integrations.
Python SDK
SardisClient
from sardis import SardisClient
client = SardisClient(
api_key="your_api_key",
base_url="https://api.sardis.sh", # Optional
timeout=30, # Optional, seconds
max_retries=3 # Optional
)Payments
# Execute a payment
result = await sardis.pay(
to="api.openai.com",
amount=20.00,
currency="USDC",
purpose="API credits"
)
result.payment_id # str
result.status # "pending" | "processing" | "completed" | "failed"
result.tx_hash # str | NoneWallets
# Get wallet balance
balance = client.wallets.get_balance(wallet_id="wallet_xxx")
# Create a new wallet
wallet = client.wallets.create(
agent_id="agent_xxx",
currency="USDC",
chain="base"
)
# List all wallets
wallets = client.wallets.list(agent_id="agent_xxx")Policy
from decimal import Decimal
# Check if a payment would be allowed
check = client.policies.check(
agent_id="agent_xxx",
amount=Decimal("500.00"),
currency="USD",
merchant_id="amazon.com"
)
check.allowed # bool
check.reason # str (if blocked)TypeScript SDK
SardisClient
import { SardisClient } from '@sardis/sdk';
const client = new SardisClient({
apiKey: 'your_api_key',
baseUrl: 'https://api.sardis.sh', // Optional
timeout: 30000, // Optional, milliseconds
maxRetries: 3 // Optional
});Payments
const result = await sardis.pay({
to: 'api.openai.com',
amount: 20.00,
currency: 'USDC',
purpose: 'API credits'
});
result.payment_id // string
result.status // string
result.tx_hash // string | undefinedFramework Integrations
LangChain (Python)
from sardis.integrations.langchain import SardisTool
tools = [SardisTool()]
# The tool automatically handles payments, policy validation, and card issuanceVercel AI SDK (TypeScript)
import { createSardisTools } from '@sardis/ai-sdk';
import { generateText } from 'ai';
const tools = createSardisTools(sardisClient);
const result = await generateText({
model: openai('gpt-4'),
tools,
prompt: 'Pay $20 to OpenAI for API credits'
});Error Handling
All SDK methods throw typed exceptions:
from sardis import (
PolicyViolationError,
InsufficientBalanceError,
AuthenticationError
)
try:
result = await sardis.pay(...)
except PolicyViolationError as e:
print(f"Blocked: {e}")
except InsufficientBalanceError:
print("Not enough funds")SDK Reference
Official Python and TypeScript SDKs for Sardis. Typed resources and validated models for wallets, payments, cards, policies, and more.
API Reference
Complete REST API reference for the Sardis Payment OS. 47+ endpoints covering wallets, payments, mandates, treasury, cards, compliance, and more.