SDKS
TypeScript SDK
The official TypeScript SDK provides full type safety, auto-completion, and idiomatic patterns for building AI agents in Node.js, Deno, and edge runtimes.
Installation
npm
npm install @yourautomation/sdk
Requirements: Node.js 18+ or any runtime with Web Streams API support.
Client Configuration
Full configuration
import { YourAutomation } from "@yourautomation/sdk";
const client = new YourAutomation({
apiKey: process.env.YA_API_KEY!,
baseUrl: "https://api.yourautomation.ai/v1", // default
timeout: 30_000, // request timeout (ms)
maxRetries: 3, // automatic retry count
retryDelay: 1000, // initial retry delay (ms)
retryBackoff: 2, // exponential backoff multiplier
debug: false, // enable request/response logging
fetch: globalThis.fetch, // custom fetch implementation
});
Agents
CRUD operations
// Create
const agent = await client.agents.create({
name: "Support Agent",
model: "claude-sonnet-4-20250514",
systemPrompt: "You are a helpful assistant...",
tools: [],
parameters: { temperature: 0.3, maxTokens: 1024 },
});
// List
const agents = await client.agents.list({ limit: 20 });
for (const a of agents.data) {
console.log(a.id, a.name, a.status);
}
// Retrieve
const fetched = await client.agents.get("agt_abc123");
// Update
const updated = await client.agents.update("agt_abc123", {
systemPrompt: "Updated prompt...",
parameters: { temperature: 0.5 },
});
// Delete
await client.agents.delete("agt_abc123");
Execution
Execute an agent
// Standard execution
const result = await client.agents.execute("agt_abc123", {
input: "What is your return policy?",
conversationId: "conv_optional",
});
console.log(result.output); // agent's response
console.log(result.toolCalls); // tools called
console.log(result.usage); // token usage
console.log(result.timing); // latency metrics
Streaming
Streaming execution
const stream = await client.agents.execute("agt_abc123", {
input: "Explain quantum computing",
stream: true,
});
for await (const event of stream) {
if (event.type === "text_delta") {
process.stdout.write(event.text);
}
if (event.type === "tool_call_start") {
console.log("Calling:", event.name);
}
if (event.type === "done") {
console.log("\nTokens:", event.usage.totalTokens);
}
}
// With AbortController
const controller = new AbortController();
const stream2 = await client.agents.execute("agt_abc123", {
input: "Write a long essay...",
stream: true,
signal: controller.signal,
});
// Cancel: controller.abort();
Type Definitions
Key types
import type {
Agent,
AgentCreateParams,
AgentUpdateParams,
Execution,
ExecutionParams,
StreamEvent,
Tool,
ToolCall,
Conversation,
Usage,
APIError,
RateLimitError,
} from "@yourautomation/sdk";
// All responses are fully typed
const agent: Agent = await client.agents.get("agt_abc123");
const result: Execution = await client.agents.execute(agent.id, {
input: "Hello",
});
Memory Operations
Memory SDK
// Create a memory store
const store = await client.memory.create({
agentId: "agt_abc123",
name: "customer-data",
type: "key-value",
});
// Set a value
await client.memory.set(store.id, {
key: "user:sarah",
value: { name: "Sarah", tier: "premium" },
ttl: 86400 * 30, // 30 days
});
// Get a value
const data = await client.memory.get(store.id, "user:sarah");
// Delete a value
await client.memory.delete(store.id, "user:sarah");
// Vector store operations
const vectorStore = await client.memory.create({
agentId: "agt_abc123",
name: "knowledge-base",
type: "vector",
});
await client.memory.addDocuments(vectorStore.id, [
{ content: "Return policy: 30 days...", metadata: { topic: "returns" } },
]);
const results = await client.memory.search(vectorStore.id, {
query: "How do returns work?",
limit: 5,
});
Pagination Helpers
Auto-pagination
// Iterate through all pages automatically
for await (const agent of client.agents.list({ limit: 50 })) {
console.log(agent.id, agent.name);
}
// Collect all into an array
const allAgents = await client.agents.list({ limit: 100 }).toArray();
// Get a specific page
const page = await client.agents.list({ limit: 20, after: "agt_abc123" });
console.log(page.data); // Agent[]
console.log(page.hasMore); // boolean
console.log(page.nextCursor); // string | null
Note
Auto-pagination respects rate limits automatically. The SDK will pause and retry if it encounters a 429 response during iteration.
Edge Runtime Support
The SDK works in Vercel Edge Functions, Cloudflare Workers, and Deno Deploy:
Edge runtime
// Vercel Edge Function
export const runtime = "edge";
export async function POST(req: Request) {
const { input } = await req.json();
const client = new YourAutomation({ apiKey: process.env.YA_API_KEY! });
const stream = await client.agents.execute("agt_abc123", {
input,
stream: true,
});
return new Response(stream.toReadableStream(), {
headers: { "Content-Type": "text/event-stream" },
});
}