Common questions and answers about Somnia AI Agent Kit.
🚀 Getting Started
Q: What is Somnia AI?
A: Somnia AI is a comprehensive platform for building, deploying, and managing AI agents on the blockchain. It combines AI capabilities (via OpenAI, Anthropic, etc.) with blockchain technology (smart contracts, on-chain registry) to create decentralized, autonomous AI agents.
Q: Do I need blockchain experience to use Somnia AI?
A: Not necessarily! While understanding blockchain basics helps, our SDK abstracts away most of the complexity. If you can write TypeScript/JavaScript, you can build AI agents with Somnia.
Q: What programming languages are supported?
A: Currently, we support TypeScript and JavaScript. Support for Python, Go, and Rust is planned for future releases.
Q: Is Somnia AI free to use?
A: The SDK is open-source and free to use. However, you'll need to pay for:
Gas fees on the blockchain (very low on Somnia)
LLM API costs (OpenAI, Anthropic, etc.)
Optional: IPFS pinning services
🤖 AI & LLM
Q: Which AI models are supported?
A: We support:
OpenAI: GPT-4, GPT-4 Turbo, GPT-3.5
Anthropic: Claude 3 Opus, Sonnet, Haiku
DeepSeek: DeepSeek Chat, DeepSeek Coder
Ollama: Any local model (Llama, Mistral, etc.)
Custom: Bring your own LLM provider
Q: Where does the AI run? On-chain or off-chain?
A: AI inference runs off-chain (client-side or via API). The blockchain stores:
Agent metadata and configuration
Execution results
Transaction history
Agent registry
This keeps costs low while maintaining decentralization. See LLM Architecture for details.
Q: Can I use local AI models (no API keys)?
A: Yes! Use Ollama to run models locally:
Q: How much do LLM API calls cost?
A: Costs vary by provider:
GPT-4: ~$0.03 per 1K input tokens, ~$0.06 per 1K output tokens
GPT-3.5: ~$0.001 per 1K tokens
Claude 3: ~$0.015 per 1K tokens
Ollama (local): Free (but requires local compute)
Use our monitoring tools to track costs in real-time.
Q: Can I switch between different AI models?
A: Yes! You can:
Switch models for different agents
Change models at runtime
Use different models for different tasks
Fallback to cheaper models when needed
⛓️ Blockchain & Smart Contracts
Q: Which blockchains are supported?
A: Currently:
Somnia Testnet (recommended)
Somnia Mainnet (coming soon)
Any EVM-compatible chain (with custom deployment)
Q: How much do transactions cost?
A: On Somnia:
Agent registration: 0.001 STM ($0.001)
Task execution: 0.0001 STM ($0.0001)
Vault operations: 0.0002 STM ($0.0002)
Somnia is optimized for high-throughput, low-cost transactions.
Q: Do I need to deploy smart contracts myself?
A: No! We provide pre-deployed contracts on Somnia Testnet and Mainnet. Just use the contract addresses from our docs.
If you want to deploy on a custom network:
Q: Can I modify the smart contracts?
A: Yes! The contracts are open-source. You can:
Fork the repository
Modify contracts
Deploy your own version
Point the SDK to your contracts
Q: What happens if a transaction fails?
A: The SDK handles failures gracefully:
Automatic retry with exponential backoff
Clear error messages
Transaction receipts for debugging
No funds lost (failed transactions are reverted)
Q: How do I get testnet tokens?
A: Visit the Somnia Faucet:
Enter your wallet address
Complete captcha
Receive testnet STM tokens
Start building!
💰 Agent Vault & Funds
Q: What is an Agent Vault?
A: An Agent Vault is a smart contract that:
Stores funds for your agent
Enforces daily spending limits
Supports multiple tokens (native + ERC20)
Provides secure withdrawals
Think of it as a bank account for your AI agent.
Q: Why do I need a vault?
A: Vaults provide:
Security: Funds are locked in a smart contract
Control: Only you can withdraw
Limits: Prevent agents from overspending
Transparency: All transactions are on-chain
Q: How do daily limits work?
A: Daily limits reset every 24 hours:
Set a limit when creating the vault
Agent can spend up to the limit per day
Limit resets automatically
Owner can adjust limits anytime
Q: Can I use stablecoins (USDC, USDT)?
A: Yes! Enable ERC20 tokens:
Q: What if my agent runs out of funds?
A: The agent will:
Fail to execute tasks
Emit an error event
Wait for you to deposit more funds
Set up monitoring to get alerts when funds are low.
🔒 Security & Privacy
Q: Is my private key safe?
A: Your private key:
Never leaves your machine (unless you deploy to a server)
Never sent to our servers
Never stored in smart contracts
Should be in .env file (never commit to Git!)
Best practices:
Use environment variables
Use hardware wallets for production
Rotate keys regularly
Use separate keys for testing
Q: Can others see my agent's prompts?
A: It depends:
LLM prompts: Sent to LLM provider (OpenAI, etc.) - they may log them
import { OllamaAdapter } from '@somnia/agent-kit/llm';
const llm = new OllamaAdapter({
baseUrl: 'http://localhost:11434',
model: 'llama2',
});
const gpt4 = new OpenAIAdapter({ model: 'gpt-4' });
const gpt35 = new OpenAIAdapter({ model: 'gpt-3.5-turbo' });
// Use GPT-4 for complex tasks
const complexResponse = await gpt4.generate({ ... });
// Use GPT-3.5 for simple tasks
const simpleResponse = await gpt35.generate({ ... });
cd contracts
npx hardhat run scripts/deploy.ts --network your-network
// Get agent address first
const agent = await kit.contracts.registry.getAgent(agentId);
const agentAddress = agent.owner;
// Create vault with 1 STM daily limit
await vault.createVault(agentAddress, ethers.parseEther('1.0'));
// Agent can spend up to 1 STM per day
// After 24 hours, limit resets