Démarrage rapide
Créez votre premier agent IA avec Astreus en moins de 2 minutes
Créons un agent simple capable d'exécuter des tâches et de répondre intelligemment.
Avant de continuer, assurez-vous qu'Astreus est installé. Si ce n'est pas encore fait, suivez le guide d'installation.
Créez votre premier agent#
Créer le fichier d'environnement#
Créez un fichier .env à la racine de votre projet et ajoutez votre clé API OpenAI :
touch .envAjoutez votre clé API dans le fichier .env :
OPENAI_API_KEY=sk-your-openai-api-key-hereCréez votre premier agent#
Créez un agent avec mémoire et invite système :
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});Créer et exécuter une tâche#
Créez une tâche et exécutez-la avec votre agent :
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a task
const task = await agent.createTask({
prompt: "Research latest news in Anthropic and OpenAI"
});
// Execute the task
const result = await agent.executeTask(task.id);
console.log(result.response);Construire un workflow Graph#
Créez un graphe de workflow avec plusieurs tâches :
import { Agent, Graph } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-6-astra',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a graph for complex workflows
const graph = new Graph({
name: 'Research Pipeline',
defaultAgentId: agent.id
});
// Add task nodes
const researchNode = graph.addTaskNode({
prompt: 'Research the latest AI developments'
});
const analysisNode = graph.addTaskNode({
prompt: 'Analyze the research findings',
dependencies: [researchNode]
});
const summaryNode = graph.addTaskNode({
prompt: 'Create a summary report',
dependencies: [analysisNode]
});
// Run the graph
const graphResult = await graph.run();
console.log(graphResult.results[summaryNode]);Félicitations ! Vous avez créé votre premier agent IA avec Astreus.