Packages
@runtimee/sdk
Developer-facing API for Runtimee
@runtimee/sdk
The SDK package is the developer-facing API for Runtimee. It provides a high-level interface to create financial actors, define policies, and spend USDC within policy-defined constraints.
Features
- Simple API: Intuitive methods to create actors and make payments.
- Policy Integration: Seamlessly works with policies defined in
@runtimee/core. - TypeScript First: Full TypeScript support with comprehensive type definitions.
- HTTP Client: Communicates with the Runtimee hosted service (or your own instance).
Key Exports
Main Classes
import {
Runtimee,
ActorClient
} from "@runtimee/sdk"Utility Functions
import {
parseUsdc,
formatUsdc
} from "@runtimee/sdk"Types
import type {
CreateActorParams,
PayParams,
PreviewPayParams,
ActorStatus,
ActorSummary,
ExecutionReceipt,
RuntimeeConfig
} from "@runtimee/sdk"Usage
Initializing the SDK
import { Runtimee } from "@runtimee/sdk"
const rt = new Runtimee({
apiKey: "your-api-key-here",
baseUrl: "https://api.runtimee.dev" // optional, defaults to this
})Creating an Actor
const actor = await rt.actors.create({
name: "my-agent",
budget: {
amount: "100", // 100 USDC
currency: "USDC",
period: "monthly"
},
policies: [
{
type: "allowlist",
config: {
allowedTargets: ["openai:gpt-4-turbo", "github:copilot"]
}
},
{
type: "max-per-call",
config: {
maxAmount: "10" // 10 USDC max per call
}
}
]
})Making a Payment
const execution = await rt.actors.pay(actor.id, {
target: "openai:gpt-4-turbo",
amount: "5", // 5 USDC
purpose: {
type: "llm-inference",
id: "chat-completion-123",
description: "GPT-4 Turbo chat completion"
}
})Previewing a Payment (Simulation)
const { decision, policyResults } = await rt.actors.previewPay(actor.id, {
target: "openai:gpt-4-turbo",
amount: "5",
purpose: {
type: "llm-inference",
id: "preview-456"
}
})
if (decision === "approved") {
// Safe to proceed with payment
} else {
// Payment would be denied by policy
console.log("Payment denied:", policyResults)
}Checking Actor Status
const status = await rt.actors.status(actor.id)
console.log(`Actor ${actor.name} has ${status.budget.remaining} USDC remaining`)Installation
npm install @runtimee/sdk
# or
pnpm add @runtimee/sdkLicense
Apache 2.0
How is this guide?