SDK Guide
The SmythOS SDK lets you define, configure, and extend agents in TypeScript.
It sits on top of the SmythOS Runtime Environment, giving you a clean API to build workflows, add skills, and connect components programmatically.
When to use the SDK
Key SDK Capabilities
Feature | What you can do with it |
---|---|
Agent API | Define, configure, and manage agents in TypeScript |
Skills | Add custom functions and API calls |
Components | Compose modular workflows (LLMs, APIs, logic, data) |
Streaming | Stream agent output for real-time applications |
Storage/VectorDB | Use built-in connectors for memory and state |
State Handling | Save and reload agent state or skills |
Getting Started
Install the SDK:
npm install @smythos/sdk
Create your first agent
import { Agent } from '@smythos/sdk';
const agent = new Agent({
name: 'Assistant',
model: 'gpt-4o',
behavior: 'You answer user questions.',
});
Add a skill
agent.addSkill({
name: 'echo',
description: 'Repeat the user input.',
process: async ({ text }) => text,
});
Prompt the agent
const result = await agent.prompt('Tell me about SmythOS.');
console.log(result);
Tip
Core Building Blocks
Agents
An agent defines a model, behavior, and skills.
const agent = new Agent({
name: 'DataBot',
model: 'gpt-4',
behavior: 'Summarizes and analyzes data.',
});
Skills
Extend agent behavior with custom skills.
agent.addSkill({
name: 'summarize',
description: 'Summarizes text.',
ai_exposed: true,
process: async ({ input }) => summarizeText(input),
});
const sum = await agent.call('summarize', { input: 'SmythOS is an agent runtime.' });
Components
Combine modular building blocks like LLMs, classifiers, or API connectors.
import { GenAILLM, Classifier } from '@smythos/sdk';
const llm = GenAILLM({ model: 'gpt-4o' }, agent);
const classifier = Classifier({ classes: ['news', 'sports'] }, agent);
classifier.in({ Input: llm.out.Reply });
Prompting and Streaming
Prompt normally:
const output = await agent.prompt('How does vector search work?');
Stream responses in real time:
const stream = await agent.prompt('Stream me this.').stream();
stream.on('data', (chunk) => process.stdout.write(chunk));
When to use streaming
Integration Patterns
You can integrate SDK agents into larger systems:
- Save or load agent state for persistence
- Use connectors for LLMs, storage, or vector databases
- Run locally for dev; customize configs for production
- Pair with Enterprise Deployment for scaling
Examples and Next Steps
Explore more in the SDK examples folder.
Recommended next docs
Combine with Studio