Skip to main content
Sonzai Docs

Agent Generation

Create agents from natural language descriptions. The platform generates personality profiles, bios, and seed memories automatically.

Generate & Create Agent

One-shot: describe an agent in natural language, get a fully provisioned agent with personality, bio, and seed memories.

import { Sonzai } from "@sonzai-labs/agents";

const client = new Sonzai({ apiKey: "sk-..." });

const agent = await client.generation.generateAndCreate({
  name: "Luna",
  description: "A cheerful and curious AI assistant who loves helping developers debug code.",
  language: "en",
});

Idempotent Updates

If an agentId is provided and the agent already exists, generateAndCreate updates the existing agent rather than creating a duplicate.

Generate Character Profile

Generate a full personality profile without creating the agent. Useful for previewing before committing.

const profile = await client.generation.generateCharacter({
  name: "Atlas",
  description: "A stoic, wise mentor who speaks in metaphors and values patience above all.",
  fields: ["big5", "dimensions", "preferences", "behaviors"],
});

Generate Bio

Generate or regenerate a biography for an existing agent.

const bio = await client.generation.generateBio("agent-id", {
  description: "A friendly barista who remembers every customer's order",
  style: "warm and conversational",
});
console.log(bio.bio);

Generate Seed Memories

Generate and optionally store backstory memories based on personality.

const memories = await client.generation.generateSeedMemories("agent-id", {
  agentName: "Luna",
  trueInterests: ["astronomy", "poetry", "hiking"],
  trueDislikes: ["loud noises", "dishonesty"],
  generateOriginStory: true,
  generatePersonalizedMemories: true,
  storeMemories: true,
});
console.log(memories.memories.length);

Generate Image

Generate images using AI from a text prompt.

const image = await client.generation.generateImage("agent-id", {
  prompt: "A serene mountain landscape at sunset",
});
console.log(image.url);