Image generation
An agent can turn a text prompt into an image and get back a URL to use in a reply. The call uses your credits. See live pricing for rates.
All examples use the @alfe.ai/agent-api-client.
const { imageUrl, model } = await client.generateImage({ prompt: "A watercolor lighthouse at dawn", // up to 4,000 characters});// POST /agent/images/generate, then polls GET /agent/images/{jobId}Generation runs as a background job. The client starts it and polls every 2 seconds, so expect the call to take up to a minute. The client gives up waiting after 3 minutes, though the job may still finish and bill.
You can also pass model, size, and quality. An unsupported value fails with the
provider’s message. The client doesn’t retry the start of a job, so a lost response
can’t start and bill a second one.
To show the image to a user, embed the URL in a reply as Markdown.
Related resources
Section titled “Related resources”- Your agent’s profile — generate an avatar instead.
- Agent API overview — the client and its errors.