Skip to main content
The Superserve TypeScript SDK provides a simple, type-safe interface for interacting with deployed agents. It supports both promise-based and streaming responses, multi-turn sessions, and React hooks for building chat interfaces.

Features

  • Type-safe client — Full TypeScript support with accurate type inference
  • Multiple usage patterns — One-shot runs, streaming responses, and multi-turn sessions
  • React hooks — Pre-built useAgent hook for chat interfaces
  • Streaming support — Real-time text streaming and tool call events via Server-Sent Events
  • Error handling — Structured error types with status codes and details
  • Automatic session management — Sessions auto-cleanup after 29 minutes of inactivity

Quick Start

Install the SDK:
npm install @superserve/sdk
Get your API key:
superserve login
This generates a token you can use with the SDK.

Basic Usage

import Superserve from '@superserve/sdk'

const client = new Superserve({ apiKey: 'ss_...' })

const result = await client.run('my-agent', {
  message: 'Hello!'
})

console.log(result.text)
// => "Hello! How can I help you?"

Package Structure

The SDK is published as a single package with multiple entry points:
  • @superserve/sdk — Core client, session, and streaming functionality
  • @superserve/sdk/react — React hooks and components
// Main exports
import Superserve from '@superserve/sdk'
import { Session, AgentStream, SuperserveError } from '@superserve/sdk'

// React exports
import { useAgent, SuperserveProvider } from '@superserve/sdk/react'

Core Concepts

Client

The Superserve class is the main entry point. Initialize it with your API key and use it to run agents or create sessions.

Sessions

Sessions enable multi-turn conversations with an agent. Messages sent within a session share context and history. Sessions automatically timeout after 29 minutes of inactivity.

Streaming

Agent responses can be streamed in real-time using Server-Sent Events. The AgentStream class provides async iterators for consuming events as they arrive.

Tool Calls

When agents use tools, the SDK tracks each invocation including name, input, and execution duration. These are included in the final RunResult.

Next Steps

Installation

Install the SDK and configure authentication

Client Reference

Learn about the Superserve client class

Sessions

Build multi-turn conversations

Streaming

Handle real-time agent responses

React Hooks

Build chat interfaces with React

Build docs developers (and LLMs) love