Installation
Install and configure the Stevora TypeScript SDK
Installation
The Stevora TypeScript SDK (@stevora/sdk) provides a typed client for the Stevora REST API. It works in any Node.js or edge runtime environment that supports the fetch API.
Install the package
npm install @stevora/sdkInitialize the client
Import the AgentRuntime class and create an instance with your API key:
import { AgentRuntime } from '@stevora/sdk';
const runtime = new AgentRuntime({
apiKey: 'stv_your_api_key',
});The constructor throws immediately if apiKey is missing.
Configuration options
The AgentRuntimeConfig object accepts the following fields:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | (required) | Your Stevora API key. Starts with stv_. |
baseUrl | string | http://localhost:3000 | Base URL of the Stevora API server. Set this to your deployed URL in production. |
timeout | number | 30000 | Request timeout in milliseconds. Applies to every HTTP call made by the SDK. |
Full configuration example
import { AgentRuntime } from '@stevora/sdk';
const runtime = new AgentRuntime({
apiKey: process.env.STEVORA_API_KEY!,
baseUrl: 'https://api.stevora.example.com',
timeout: 15000,
});Resource namespaces
Once initialized, the client exposes four resource namespaces:
| Namespace | Description |
|---|---|
runtime.workflows | Create, list, cancel, resume, and monitor workflow runs |
runtime.definitions | Manage workflow definitions |
runtime.approvals | List and decide on human-in-the-loop approval requests |
runtime.costs | Query aggregated cost data across your workspace |
There is also a top-level health() method:
const status = await runtime.health();
// { status: 'ok', checks: { database: 'ok', queue: 'ok' } }Error handling
All SDK methods throw an AgentRuntimeError when the API returns a non-success response. Import it to catch errors with full context:
import { AgentRuntime, AgentRuntimeError } from '@stevora/sdk';
const runtime = new AgentRuntime({ apiKey: 'stv_your_api_key' });
try {
await runtime.workflows.get('nonexistent');
} catch (err) {
if (err instanceof AgentRuntimeError) {
console.log(err.code); // 'NOT_FOUND'
console.log(err.statusCode); // 404
console.log(err.message); // "WorkflowRun 'nonexistent' not found"
console.log(err.details); // additional context, if any
}
}The AgentRuntimeError class extends Error and has the following properties:
| Property | Type | Description |
|---|---|---|
message | string | Human-readable error description |
code | string | Machine-readable error code (e.g., NOT_FOUND, VALIDATION_ERROR) |
statusCode | number | HTTP status code from the API response |
details | unknown | Optional additional error context |
ESM only
The SDK is published as an ES module ("type": "module" in its package.json). If your project uses CommonJS, you will need to use dynamic import() or update your project configuration to support ESM imports.