Setup and Prerequisites
This guide covers the initial setup required to run Robota SDK examples.
Prerequisites
Node.js and Package Manager
Ensure you have the following installed:
- Node.js 18+
- pnpm (recommended) or npm
- bun (optional, for faster execution)
bash
# Install pnpm if not already installed
npm install -g pnpm
# Install bun (optional, for faster TypeScript execution)
curl -fsSL https://bun.sh/install | bashInstall Dependencies
From the project root:
bash
pnpm installEnvironment Configuration
Required API Keys
Create a .env file in the project root with your API keys:
env
# Required for most examples
OPENAI_API_KEY=your_openai_api_key_here
# Optional - for multi-provider examples
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GOOGLE_API_KEY=your_google_api_key_hereGetting API Keys
OpenAI API Key
- Visit OpenAI Platform
- Sign up or log in to your account
- Navigate to API Keys section
- Create a new API key
- Copy the key to your
.envfile
Anthropic API Key (Optional)
- Visit Anthropic Console
- Sign up or log in
- Navigate to API Keys
- Create a new key
- Add to your
.envfile
Google AI API Key (Optional)
- Visit Google AI Studio
- Sign in with your Google account
- Create a new API key
- Add to your
.envfile
Directory Structure
Examples are distributed per package (SSOT ownership). There is no single shared apps/examples folder.
robota/
├── docs/examples/ # This documentation
└── packages/ # SDK packages
├── agents/
│ └── examples/ # @robota-sdk/agent-core examples
├── openai/
│ └── examples/ # @robota-sdk/agent-provider-openai examples
├── team/
│ └── examples/ # @robota-sdk/agent-team examplesRunning Examples
Method 1: Direct Execution (Recommended)
bash
# Build packages first (recommended)
pnpm build
# Run a package-owned example from the repo root
pnpm tsx packages/agents/examples/basic-conversation.tsVerification
Test your setup with the simplest example:
bash
pnpm tsx packages/agents/examples/basic-conversation.tsExpected output:
===== Simple Conversation Example =====
Response: [AI response about TypeScript]
===== Streaming Response Example =====
Response: [Streaming AI response about TypeScript advantages]Troubleshooting Setup Issues
Common Problems
1. Missing Dependencies
bash
# Reinstall dependencies
rm -rf node_modules package-lock.json
pnpm install2. API Key Issues
- Verify API keys are correctly set in
.env - Check for extra spaces or quotes around keys
- Ensure
.envis in the project root, not in examples directory
3. TypeScript Execution Errors
bash
# Install tsx globally if needed
pnpm add -g tsx
# Or use npx
npx tsx 01-basic/01-simple-conversation.ts4. Module Resolution Issues
bash
# Build packages first
pnpm buildGetting Help
If you encounter issues:
- Check the specific example documentation
- Verify your environment configuration
- Ensure all dependencies are installed
- Check the console for specific error messages
Next Steps
Once setup is complete, explore the examples:
- Start with Basic Conversation
- Try AI with Tools
- Explore Multi-Provider Setup
Environment Variables Reference
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY | Yes | OpenAI API key for GPT models |
ANTHROPIC_API_KEY | No | Anthropic API key for Claude models |
GOOGLE_API_KEY | No | Google AI API key for Gemini models |
Examples should fail fast when required environment variables are missing.