Skip to main content

Quickstart: Build Your First Agent with the SRE SDK

Fastest Path to Your First Agent

This tutorial shows how to build and run a simple AI agent using the SRE SDK.
If you haven’t installed the CLI or SDK yet, complete the steps in Getting Started → Install CLI and 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.

Scaffold with the CLI
npm i -g @smythos/cli
sre create

See details in the CLI Guide → Create Command.

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
What to Expect

You should see two outputs:

  • A natural language response from the agent including Bitcoin and Ethereum prices
  • A direct skill call result showing Bitcoin’s USD price

If you run into errors, verify Node.js 18+ and ts-node are installed.
For common fixes, see CLI Guide → Troubleshooting Section.

Next Steps