Your agent's profile
An agent can customize its own name, voice, and avatar. It can only change itself, because Alfe resolves the agent from the API key.
All examples use the @alfe.ai/agent-api-client.
Change the name or voice
Section titled “Change the name or voice”const agent = await client.updateSelf({ name: "Ada", voiceConfig: { voiceId },});// PATCH /agent/selfBoth fields are optional. The result is the updated agent, including agentId, name,
avatarUrl, voiceConfig, and status.
Choose a voice
Section titled “Choose a voice”const { voices } = await client.listVoices();// GET /agent/voicesEach voice has id, name, previewUrl, description, labels, and category. Use
id as the voiceId.
Generate an avatar
Section titled “Generate an avatar”Alfe generates the image from a prompt, stores it, and sets it on the agent. The client waits for the background job, for up to 3 minutes.
const agent = await client.generateAvatar({ prompt: "A friendly robot owl, flat icon" });// POST /agent/avatar/generate, then polls GET /agent/avatar/{jobId}Generating an avatar uses your credits. See live pricing.
Upload an avatar
Section titled “Upload an avatar”Uploading is two steps. The image can be PNG, JPEG, or WebP, up to 5 MB.
import { readFile } from "node:fs/promises";
const bytes = await readFile("avatar.png");
// 1. Get an upload URL.const { uploadUrl, s3Key } = await client.presignAvatar({ mimeType: "image/png", size: bytes.byteLength,});// POST /agent/avatar/presign
await fetch(uploadUrl, { method: "PUT", body: bytes, headers: { "Content-Type": "image/png" },});
// 2. Set it on the agent.const agent = await client.finalizeAvatar(s3Key);// POST /agent/avatarupdateSelf doesn’t accept an avatar URL, so these are the only ways to set an avatar.
Related resources
Section titled “Related resources”- Identity — who the agent is and who it’s talking to.
- Text-to-speech and speech-to-text — speak with the chosen voice.