πŸš€Quick Start

Get your first AI agent running in 5 minutes with Somnia Agent Kit!

πŸ“‹ Prerequisites

Before you begin, make sure you have:

  • βœ… Node.js 18+ installed

  • βœ… npm or pnpm package manager

  • βœ… A wallet with testnet tokens (for blockchain transactions)

  • βœ… An LLM API key (OpenAI, DeepSeek) or Ollama installed locally

πŸ“¦ Step 1: Installation

# Using npm
npm install somnia-agent-kit

# Using pnpm (recommended)
pnpm add somnia-agent-kit

# Using yarn
yarn add somnia-agent-kit

πŸ”‘ Step 2: Environment Setup

Create a .env file in your project root:

circle-info

Getting Testnet Tokens: Visit the Somnia Faucetarrow-up-right to get free testnet tokens.

circle-exclamation

🎯 Step 3: Your First Agent

Create a file my-first-agent.ts:

▢️ Step 4: Run Your Agent

πŸ“Š Expected Output

πŸš€ Step 5: Register Your Own Agent

Now let's register your own agent:

🧠 Step 6: Add AI with LLM

Let's add AI capabilities using Ollama (FREE local AI):

circle-info

Using Ollama (FREE):

🎯 What Just Happened?

  1. βœ… Installed SDK - Added somnia-agent-kit package

  2. βœ… Initialized SDK - Connected to Somnia blockchain

  3. βœ… Queried Agents - Read data from smart contracts

  4. βœ… Registered Agent - Created your own agent on-chain

  5. βœ… Added AI - Integrated LLM for intelligent responses

πŸš€ Next Steps

Now that you have a working setup, explore more:

πŸ“š Learn Core Concepts

πŸ’‘ Try Examples

Working Code Examples:

πŸ› οΈ Advanced Topics

πŸ†˜ Troubleshooting

Common Issues

Problem: "Insufficient funds" error

Problem: "Contract not deployed" error

Problem: "Ollama connection failed"

Problem: TypeScript errors

Need Help?

πŸŽ“ Quick Reference

Essential Commands

Essential Imports

Key Concepts

Concept
Description

SomniaAgentKit

Main SDK class for blockchain interaction

Agent

Autonomous AI entity with lifecycle management

Registry

Smart contract storing agent metadata

Executor

Handles agent task execution

Vault

Manages agent funds with daily limits

LLM Adapter

Interface to AI models (OpenAI, Ollama, etc.)

Network Configuration


Ready to build something amazing? πŸš€ Your agent is live and ready to help users!

Last updated