最初のエージェント

Astreusフレームワークを使って最初のAIエージェントを作成します。

クイックスタート#

完全なサンプルをクローンする#

最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。

bash
git clone https://github.com/astreus-ai/examples
cd examples/your-first-agent
npm install

またはパッケージのみをインストール#

ゼロから構築したい場合は次のようにします。

bash
npm install @astreus-ai/astreus

環境設定#

bash
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db

基本的なエージェント#

typescript
import { Agent } from '@astreus-ai/astreus';

const agent = await Agent.create({
  name: 'MyFirstAgent',
  model: 'gpt-6-astra',
  systemPrompt: 'You are a helpful assistant.'
});

// Create and execute a task
const task = await agent.createTask({
  prompt: "Hello, introduce yourself"
});

const result = await agent.executeTask(task.id);
console.log(result.response);

サンプルの実行#

リポジトリをクローンした場合は次を実行します。

bash
npm run dev

ゼロから構築した場合は、上記のコードを含むindex.tsファイルを作成し、次を実行します。

bash
npx tsx index.ts

リポジトリ#

完全なサンプルはGitHubで公開されています: examples/your-first-agent