Installation

Set up Daydreams and configure your development environment.

Get an API key

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:

create-agent.sh
npx @daydreamsai/create-agent my-agent

This 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):

create-agent-with-extensions.sh
# With specific extensions
npx @daydreamsai/create-agent my-agent --twitter --discord --cli

# With all extensions
npx @daydreamsai/create-agent my-agent --all

Available 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:

package-install.sh
pnpm init -y
pnpm add typescript tsx @types/node @daydreamsai/core @daydreamsai/cli
package-install.sh
npm init -y
npm install typescript tsx @types/node @daydreamsai/core @daydreamsai/cli
package-install.sh
bun init -y
bun add typescript tsx @types/node @daydreamsai/core @daydreamsai/cli
package-install.sh
yarn init -y
yarn add typescript tsx @types/node @daydreamsai/core @daydreamsai/cli

Install 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/anthropic for Claude
  • @ai-sdk/google for Gemini
  • And many more...

Create your environment file:

bash
# Create .env file
cp .env.example .env

Add your API keys:

.env
OPENAI_API_KEY=your_openai_api_key_here
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
# GEMINI_API_KEY=your_gemini_api_key_here

Create your first agent file (index.ts):

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:

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.