Quickstart: Build Your First Agent with the SRE SDK
Step 1: Create a New Project
The recommended way is to scaffold a new project with the CLI. This generates the correct folder structure and configuration.
You can also create a folder manually if you prefer, but the CLI is faster and less error-prone.
Step 2: Install the SDK
Move into your project folder and install the SDK:
npm install @smythos/sdk
If you want to add the SDK to an existing Node.js project, follow Getting Started → Direct SDK Installation.
Step 3: Build Your First Agent
Create index.ts in your project folder. This example defines an agent, adds a skill, and shows how to use it both via natural language and direct calls.
import { Agent } from '@smythos/sdk';
async function main() {
const agent = new Agent({
name: 'CryptoMarket Assistant',
behavior: 'Track and report cryptocurrency prices in USD.',
model: 'gpt-4o',
});
agent.addSkill({
name: 'MarketData',
description: 'Fetch market data for a cryptocurrency',
process: async ({ coin_id }) => {
const url = `https://api.coingecko.com/api/v3/coins/${coin_id}?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false`;
const response = await fetch(url);
const data = await response.json();
return data.market_data;
},
});
// Ask the agent to use its skill
const response = await agent.prompt('What are the current prices of Bitcoin and Ethereum?');
console.log('Agent response:', response);
// Call the skill directly
const direct = await agent.call('MarketData', { coin_id: 'bitcoin' });
console.log('Direct price for Bitcoin:', direct.current_price.usd);
}
main().catch(console.error);
If you are new to skills and prompts, see SDK Guide → Skills Section for how agents decide when to call a skill.
Step 4: Run Your Agent
Run your agent using ts-node:
ts-node index.ts
If you run into errors, verify Node.js 18+ and ts-node
are installed.
For common fixes, see CLI Guide → Troubleshooting Section.
Next Steps
- Extend your skill to include 24h price change, volume, or market cap. See SDK Guide → Skill Examples.
- Replace raw
fetch
calls with the reusable APICall component. - Learn how to debug and monitor agents in Runtime Overview → Monitoring and Debugging.
- Explore real agents like RAG search and API integrations in the SRE GitHub examples.