Introduction
A TypeScript agent SDK for Azure OpenAI
Stratus is a TypeScript SDK for building AI agents powered by Azure OpenAI. It provides a clean, composable API for multi-turn conversations, tool use, multi-agent handoffs, streaming, guardrails, and tracing.
Why this exists
Azure OpenAI's v1 API lets you use the standard OpenAI() client, point it at your Azure endpoint, and things mostly just work. But "mostly" isn't good enough for production.
The OpenAI SDK gives you chat.completions.create(). Everything else - the tool loop, agent abstractions, streaming, error handling, multi-agent orchestration - is on you:
- Tool calling requires a manual loop. Stratus handles the entire tool loop - one
run()call with parallel execution, validation, and error recovery. - No agent abstraction. Stratus gives you composable agents with instructions, tools, guardrails, and handoffs in a single config object.
- Basic streaming. Stratus provides typed stream events -
content_delta,tool_call_start,tool_call_done- with accumulation and a finalRunResult. - Opaque content filter errors. Stratus throws a typed
ContentFilterErrorinstead of Azure's buriedinner_error.content_filter_results. - No multi-agent orchestration. Handoffs, subagents, guardrails, and hooks are first-class.
- Responses API support. Both Chat Completions and Responses API through the same
Modelinterface - swap with one line.
The goal: clean, typed, zero-config for the common case - while properly wrapping Azure's unique capabilities.
Features
Agents
Define agents with instructions, tools, and model settings
Sessions
Multi-turn conversations with save/resume/fork
Tools
Type-safe tool definitions with Zod schema validation
Subagents
Delegate work to child agents as tool calls
Streaming
Real-time streaming with abort signal cancellation
Structured Output
Parse model output into typed objects via Zod
Handoffs
Route conversations between specialized agents
Hooks
Lifecycle callbacks with permission control (allow/deny/modify)
Guardrails
Input and output validation with tripwire support
Tracing
Built-in span-based tracing via AsyncLocalStorage
Usage & Cost Tracking
Built-in cost estimation, budget limits, and reasoning token tracking
Quick Example
import { AzureChatCompletionsModel } from "stratus";
import { createSession, tool } from "stratus/core";
import { z } from "zod";
const model = new AzureChatCompletionsModel({
endpoint: process.env.AZURE_ENDPOINT!,
apiKey: process.env.AZURE_API_KEY!,
deployment: "gpt-5.2",
});
const getWeather = tool({
name: "get_weather",
description: "Get current weather for a city",
parameters: z.object({ city: z.string() }),
execute: async (_ctx, { city }) => `72°F and sunny in ${city}`,
});
await using session = createSession({
model,
instructions: "You are a weather assistant.",
tools: [getWeather],
});
session.send("What's the weather in NYC?");
for await (const event of session.stream()) {
if (event.type === "content_delta") process.stdout.write(event.content);
}
// Multi-turn: context persists automatically
session.send("What about London?");
for await (const event of session.stream()) {
if (event.type === "content_delta") process.stdout.write(event.content);
}Architecture
Stratus is organized into two layers:
| Package | Description |
|---|---|
stratus/core | Provider-agnostic: Agent, Session, run loop, tools, handoffs, guardrails, hooks, tracing |
stratus | Re-exports core + Azure OpenAI implementation |
The core layer defines the Model interface. Azure is the built-in implementation, but you can plug in any provider by implementing Model.
Guides
End-to-end examples showing how to combine features into real agents:
Agentic Tool Use
Tool loops, parallel calls, context, streaming, and control
Real-Time Streaming
Stream to CLI, SSE endpoints, and multi-turn sessions
Customer Support Agent
Multi-agent triage with handoffs, hooks, and guardrails
Research Agent
Orchestrate subagents for web research and data analysis
Data Extraction Pipeline
Structured output with validation guardrails and batch processing
Project Structure
Last updated on