Installation
Set up Daydreams and configure your development environment.
Get an API key
- DreamsRouter ->
DREAMSROUTER_API_KEY - Google Gemini ->
GEMINI_API_KEY - OpenAI ->
OPENAI_API_KEY - Anthropic ->
ANTHROPIC_API_KEY - Groq ->
GROQ_API_KEY - Other providers are supported by ai-sdk.dev
Installation
There are two ways to get started with Daydreams:
The quickest way to get started is using the create-agent command:
Run the create-agent command:
npx @daydreamsai/create-agent my-agentThis will:
- Create a new directory for your agent
- Set up package.json with necessary dependencies
- Create an index.ts file with your selected extensions
- Generate a .env.example file with required environment variables
- Install all dependencies
Choose your extensions when prompted (or use flags):
# With specific extensions
npx @daydreamsai/create-agent my-agent --twitter --discord --cli
# With all extensions
npx @daydreamsai/create-agent my-agent --allAvailable extensions:
--cli: Include CLI extension--twitter: Include Twitter extension--discord: Include Discord extension--telegram: Include Telegram extension--all: Include all extensions
Configure your environment variables in the generated .env file and start
building!
For more control over your setup, you can install manually:
Initialize your project and install core packages:
pnpm init -y
pnpm add typescript tsx @types/node @daydreamsai/core @daydreamsai/clinpm init -y
npm install typescript tsx @types/node @daydreamsai/core @daydreamsai/clibun init -y
bun add typescript tsx @types/node @daydreamsai/core @daydreamsai/cliyarn init -y
yarn add typescript tsx @types/node @daydreamsai/core @daydreamsai/cliInstall an LLM provider SDK:
bash title="package-install.sh" pnpm add @ai-sdk/openai
bash title="package-install.sh" npm install @ai-sdk/openai
bash title="package-install.sh" bun add @ai-sdk/openai
bash title="package-install.sh" yarn add @ai-sdk/openai
Other supported providers from ai-sdk.dev:
@ai-sdk/anthropicfor Claude@ai-sdk/googlefor Gemini- And many more...
Create your environment file:
# Create .env file
cp .env.example .envAdd your API keys:
OPENAI_API_KEY=your_openai_api_key_here
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
# GEMINI_API_KEY=your_gemini_api_key_hereCreate your first agent file (index.ts):
import { createDreams, LogLevel } from "@daydreamsai/core";
import { cliExtension } from "@daydreamsai/cli";
import { openai } from "@ai-sdk/openai";
const agent = createDreams({
logLevel: LogLevel.DEBUG,
model: openai("gpt-4o"),
extensions: [cliExtension],
});
// Start the agent
await agent.start();Add run scripts to your package.json:
{
"scripts": {
"dev": "tsx index.ts",
"start": "node index.js"
}
}Run your agent:
bash title="run-dev.sh" pnpm dev bash title="run-dev.sh" npm run dev bash title="run-dev.sh" bun dev bash title="run-dev.sh" yarn dev Next Steps
Now you can start building your first agent! Check out the concepts section to learn about the core building blocks.