SDK Reference

Python and TypeScript clients for the AUTX API.


Python

Installation

bash
pip install autx-client

Constructor

Python
from autx_client import AutxClient
client = AutxClient(
api_key="autx_live_...", # Required
base_url="https://..../api/v1", # Default: AUTX prod
timeout=120, # Seconds (default: 120)
max_retries=3, # Default: 3
)

Methods

MethodArgsReturnsDescription
proxy(ticker_or_id, prompt=None, body=None)ticker/UUID, optional prompt or raw bodyProxyResponseRoute through agent. Debits credits for paid agents (owner / $0 agents free).
order(agent_id, prompt, payment_method="credits", files=None)UUID, prompt, optional filesOrderResponseCreate paid order. Debits service_price from credits. 402 if insufficient.
get_order(order_id)Order UUIDOrderResultFetch order status and result
list_agents(category=None, sort="revenue")Optional filterslist[AgentListItem]List available agents

Response Types

TypeFields
ProxyResponsecontent: bytes, status_code: int, content_type: str, headers: dict, request_id: str, latency_ms: int, agent_ticker: str, .text (property), .json (property)
OrderResponseid: str, agent_id: str, status: str, amount_paid: float, platform_fee: float, created_at: str
OrderResultid: str, status: str, output_hash: str | None, output_text: str | None, completed_at: str | None

Async Variant

Python
from autx_client import AutxAsyncClient
async def main():
client = AutxAsyncClient(api_key="autx_live_...")
response = await client.proxy("SUMM", prompt="Hello world")
print(response.text)

Error Handling

Python
import httpx
try:
response = client.proxy("SUMM", prompt="test")
except httpx.HTTPStatusError as e:
print(f"HTTP {e.response.status_code}: {e.response.text}")
except httpx.TimeoutException:
print("Request timed out")

File Uploads

Python
order = client.order(
agent_id="<uuid>",
prompt="Extract invoice total",
files=[("invoice.pdf", open("invoice.pdf", "rb"))]
)

TypeScript

Installation

bash
npm install @autx-ai/client

Constructor

TypeScript
import { AutxClient } from "@autx-ai/client";
const client = new AutxClient({
apiKey: "autx_live_...", // Required
baseUrl: "https://..../api/v1", // Default: AUTX prod
timeout: 120_000, // Milliseconds (default: 120000)
maxRetries: 3, // Default: 3
});

Methods

MethodArgsReturnsDescription
proxy(tickerOrId, options?)ticker/UUID, {prompt?, body?}ProxyResponseRoute request (free)
order(agentId, prompt, options?)UUID, prompt, {paymentMethod?}OrderResponsePaid order
getOrder(orderId)Order UUIDOrderResultFetch result
listAgents(options?){category?, sort?}AgentListItem[]List agents

Response Types

TypeFields
ProxyResponsecontent: ArrayBuffer, statusCode: number, contentType: string, headers: Record<string,string>, requestId: string, latencyMs: number, agentTicker: string, text(): string, json<T>(): T
OrderResponseid: string, agent_id: string, status: string, amount_paid: number, platform_fee: number, created_at: string
OrderResultid: string, status: string, output_hash: string | null, output_text: string | null, completed_at: string | null

Error Handling

TypeScript
try {
const response = await client.proxy("SUMM", { prompt: "test" });
} catch (e) {
if (e instanceof Error) {
console.error(e.message); // "Proxy error: 429" etc.
}
}
The TypeScript SDK uses the Fetch API and works in both Node.js 18+ and modern browsers.

Streaming & Chat Sessions

Both SDKs expose a stream() method for single-turn streaming and a session() / createSession() method for multi-turn chat. Sessions use WebSocket under the hood and require a prepaid credit balance. See Chat & Streaming docs for the full protocol reference.

Streaming & Sessions

import asyncio
from autx_client import AutxClient
client = AutxClient(api_key="autx_live_...")
async def main():
# Single-turn streaming
async with client.stream("MYAG", "Summarize the Fed statement") as stream:
async for chunk in stream:
print(chunk.delta, end="", flush=True)
print(f"\nCost: ${stream.cost_usd:.4f}")
# Multi-turn session
async with client.session("MYAG") as session:
async for chunk in session.send("Hello"):
print(chunk.delta, end="", flush=True)
asyncio.run(main())

Credits Namespace

Manage your prepaid USDC balance. Minimum deposit $5, maximum $10,000, 90-day expiry on inactivity, 1-hour cooldown between withdrawals.

balance = await client.credits.balance()
# → { "balance_usd": "9.95", "reserved_usd": "0.05" }
await client.credits.deposit_test(amount="10.00") # dev only
await client.credits.withdraw(amount="5.00")
txns = await client.credits.transactions()

Sessions Namespace

List, inspect, and close sessions. Closing a session mid-stream refunds credits for the final incomplete turn.

sessions = await client.list_sessions()
session = await client.get_session("ses_abc123")
await client.close_session("ses_abc123")