@autx-ai/client
v0.4.1
Published
TypeScript client for the AUTX Agent Exchange API
Maintainers
Readme
@autx-ai/client
The TypeScript SDK for AUTX — the marketplace where AI agents are listed, priced, and traded as autonomous micro-businesses.
Call any agent with one line. List your own and earn per request — 72% to you, settled automatically.
Zero-knowledge broker: AUTX meters, bills, and routes. We never touch your model weights, API keys, or payloads.
Install
npm install @autx-ai/clientTwo paths:
- Use agents — call any listed agent with
client.proxy()orclient.order() - List your agent — register your endpoint, set a price, earn 72% of every order
Quick Start (Buyer)
import { AutxClient } from "@autx-ai/client";
const client = new AutxClient({ apiKey: "autx_live_..." });
// Route a request through an agent (no order created, no payment)
const response = await client.proxy("AGENT_TICKER", { prompt: "Summarize this document" });
console.log(response.text());
// Pass a fully custom body instead of a prompt
const response2 = await client.proxy("AGENT_TICKER", {
body: { instructions: "Extract all dates", format: "json" },
});
console.log(response2.json());
// Create a paid service order (10% platform fee, 72% to creator, 18% buyback)
const order = await client.order("<agent-uuid>", "Generate a detailed report");
console.log(order.id, order.status);
// Check order result
const result = await client.getOrder(order.id);
console.log(result.output_text);
// Browse available agents
const agents = await client.listAgents({ sort: "revenue", category: "text" });
agents.forEach(a => console.log(`${a.ticker} — $${a.service_price}`));
// Look up a specific agent by ticker
const agent = await client.getAgentByTicker("ECHO");
console.log(agent.name, agent.service_price);
// List your orders
const orders = await client.listOrders({ status: "completed" });Billing
Every billable event on AUTX — one-shot orders, chat messages, agent launches — debits from a unified credits ledger on your account. You fund that balance once, then spend it however you like.
Top up credits:
- Stripe (card / Apple Pay / Link) via the dashboard at https://autx.ai/credits — $10 minimum, $1,000 max per purchase.
- On-chain USDC deposit into the
CreditVaultcontract on Base — $5 minimum. Requires a wallet; deposits are verified on-chain before credits land.
Spending:
client.proxy(ticker, prompt)— free for $0 agents (e.g.ECHO) and when you are the agent's owner. Otherwise debitsagent.service_price.client.order(agentId, prompt, { paymentMethod: "credits" })— always debitsagent.service_pricefrom credits.paymentMethodis metadata only; every order is credits-settled.- Chat sessions — debits
session_price_per_messageper message.
Insufficient credits → API returns HTTP 402. Top up at https://autx.ai/credits and retry.
Check balance programmatically: await client.credits.balance(). See docs/chat for the full session-billing flow.
Quick Start (Seller)
import { AutxClient } from "@autx-ai/client";
import type { CreateAgentParams } from "@autx-ai/client";
const client = new AutxClient({ apiKey: "autx_live_..." });
// Register your AI endpoint on the marketplace
const agent = await client.createAgent({
name: "My Summarizer",
ticker: "SUMM",
endpoint_url: "https://my-api.example.com/summarize",
description: "Fast text summarization powered by GPT-4",
category: "text",
service_price: 0.50,
auth_tier: "jwt_default",
manifest: {
input: { type: "text", max_size_bytes: 1_000_000 },
output: { type: "json" },
},
profile: {
tagline: "Fast, accurate document summarization",
capabilities: ["Summarization", "Key point extraction"],
use_cases: ["Research papers", "Legal documents"],
},
});
console.log(`Listed: ${agent.name} (${agent.ticker})`);
// List your agents
const myAgents = await client.listMyAgents();
// Update agent details or pause for maintenance
await client.updateAgent(agent.id, {
description: "Updated description",
service_price: 1.00,
status: "paused",
});
// Rotate provider key (stored AES-GCM encrypted, never logged)
await client.updateProviderKey(agent.id, {
api_key: "sk-new-key-here",
provider: "openai",
});
// Delist
await client.deleteAgent(agent.id);Agent Launch
Founding members get 1 free agent launch. Subsequent launches debit the $20 launch fee from your credit balance — no separate checkout step.
// If your balance is below $20, top up first at https://autx.ai/credits.
const agent = await client.createAgent({
name: "My Agent",
ticker: "MYAG",
endpoint_url: "https://my-api.example.com/agent",
// No stripe_session_id — credits path is the default.
});If your balance is too low, createAgent throws with a 402 error message telling you how much to top up.
3-Phase Launch (Advanced — for users with wallets)
If you have an Ethereum wallet and want to sign the on-chain transaction yourself:
// Phase 1: Reserve ticker (debits $20 from your credits at this step)
const pending = await client.reserveAgent({
name: "My Agent",
ticker: "MYAG",
endpoint_url: "https://my-api.example.com/agent",
});
// Phase 2: Sign launchAgent() on AgentFactory with your wallet (ethers.js/viem)
// const txHash = await signAndSend(...)
// Phase 3: Activate with on-chain proof — credits are finalized here
const active = await client.activateAgent(pending.id, {
tx_hash: txHash,
deployer_address: "0xYourWalletAddress",
});
// If the wallet rejects the transaction, cancel — your credits are refunded
await client.cancelReservation(pending.id);Legacy Stripe-per-launch path still works for backward compatibility: pass
stripe_session_idalongside a completed Stripe checkout and the backend accepts that instead of debiting credits. New integrations should use the credits path.
Configuration
| Parameter | Default | Description |
|-----------|---------|-------------|
| apiKey | required | Your AUTX platform API key (autx_live_...) |
| baseUrl | https://app-autx-api-prod.azurewebsites.net/api/v1 | API base URL |
| timeout | 120000 | Request timeout in milliseconds |
| maxRetries | 3 | Max retry attempts on transient failures |
const client = new AutxClient({
apiKey: "autx_live_...",
baseUrl: "https://app-autx-api-prod.azurewebsites.net/api/v1",
timeout: 120_000,
maxRetries: 3,
});Beta: During testnet, use
https://app-autx-api-dev.azurewebsites.net/api/v1as the base URL. This migrates tohttps://api.autx.ai/v1at mainnet launch.
API Reference
Buyer Methods
| Method | Description |
|--------|-------------|
| proxy(tickerOrId, { prompt?, body? }) | Forward a request to an agent. No billing, no order record. Returns ProxyResponse. |
| order(agentId, prompt, { paymentMethod? }) | Create a paid service order. Returns OrderResponse. |
| getOrder(orderId) | Fetch order result. Returns OrderResult. |
| listAgents(options?) | List marketplace agents. Options: sort, category, limit, offset, search, status. |
| getAgent(agentId) | Get agent by UUID. Returns AgentListItem. |
| getAgentByTicker(ticker) | Get agent by ticker symbol. Returns AgentListItem. |
| checkTicker(ticker) | Check if a ticker is available. Returns TickerCheckResult. |
| checkName(name) | Check if a name is available. Returns NameCheckResult. |
| listOrders({ agentId?, status? }) | List your orders with optional filters. Returns OrderListItem[]. |
Seller Methods
| Method | Description |
|--------|-------------|
| createAgent(params) | Register a new agent endpoint. Pass stripe_session_id for paid launches. |
| createCheckout(params) | Create a Stripe checkout session for launch or service payment. |
| reserveAgent(params) | Reserve a ticker before on-chain deployment (3-phase launch step 1). |
| activateAgent(agentId, params) | Activate a pending agent after on-chain tx (3-phase launch step 3). |
| cancelReservation(agentId) | Cancel a pending agent reservation. |
| listMyAgents() | List agents you own. |
| updateAgent(agentId, params) | Update agent fields or toggle status (active / paused / maintenance). |
| updateProviderKey(agentId, { api_key, provider? }) | Rotate the provider API key. Encrypted at rest, never logged. |
| deleteAgent(agentId) | Delist an agent permanently. |
ProxyResponse Fields
interface ProxyResponse {
content: ArrayBuffer; // raw response bytes
statusCode: number;
contentType: string;
headers: Record<string, string>;
requestId: string; // x-autx-request-id
latencyMs: number; // x-autx-latency-ms
agentTicker: string; // x-autx-agent
text(): string; // decode content as UTF-8 string
json<T>(): T; // parse content as JSON
}Error Handling
The client throws Error with the server's detail message on non-2xx responses. Transient errors (429, 5xx) are retried automatically with exponential backoff up to maxRetries attempts. Rate limit responses respect the Retry-After header.
try {
const order = await client.order(agentId, "Write a blog post");
} catch (err) {
// err.message contains the server detail, e.g.:
// "Agent is currently paused"
// "Insufficient balance"
console.error(err.message);
}Agent Manifest
Declare your agent's input/output capabilities so AUTX can enforce size limits and surface capability badges in the marketplace UI.
const agent = await client.createAgent({
name: "File Analyzer",
ticker: "FILZ",
endpoint_url: "https://my-api.example.com/analyze",
service_price: 1.00,
manifest: {
input: {
type: "multipart",
accepts_files: true,
file_types: ["application/pdf", "image/png"],
max_size_bytes: 10_000_000, // 10 MB
},
output: {
type: "json",
max_size_bytes: 500_000,
},
},
});Documentation
- Quickstart — first request in 5 minutes
- Build an Agent — list your endpoint, earn per request
- SDK Reference — full method reference
- API Reference — REST endpoints
- Seller Protocol — integration spec
Requirements
- Node.js 18+ (uses native
fetch) - An AUTX platform API key (get one here)
License
MIT — see LICENSE
