Skip to main content

title: ‘Image Generation’ description: “Blend Animus’ automatic media workflows with direct API control for character renders, photo edits, and more.” icon: ‘image’

Image generation now ships with a unified set of REST endpoints (/generation/*) alongside the automatic workflows inside the Animus SDK. You can let the SDK detect when an assistant promises an image, or call the media API directly when you need precise control.
Looking for the HTTP endpoints? Jump to the REST Image Generation guide.

How It Works

Two-Phase Process

Image generation operates in two phases:
  1. Detection Phase: The API analyzes the conversation to determine if the assistant has agreed to send an image
  2. Generation Phase: If an image is requested, the SDK automatically generates it using the provided prompt

Basic Usage

Enable Image Generation

Enable automatic image generation in your client configuration:
Important: Automatic image generation and adding images to message history only happens when using the chat.send() method. If you’re using chat.completions(), you’ll need to manually call client.generateImage() or use your own custom/3rd party image generation endpoint.

Listen for Image Generation Events

Set up event listeners to handle the image generation process:

Direct Image Generation

Manual Image Generation

You can also generate images directly without going through chat:

Custom Image Prompts

Generate images with detailed prompts:

Integration with Other Features

Image Generation with AutoTurn

Image generation works seamlessly with conversational turns:

Image Generation Coordination

Image generation intelligently coordinates with other features:
  • After AutoTurn: Images are generated only after all conversation turns are complete
  • Follow-up Protection: Follow-up requests are blocked immediately after image generation to prevent loops
  • Event Sequencing: Events are emitted in the correct order for proper UI updates

Advanced Image Generation

Custom Image Generation Settings

While the SDK handles image generation automatically, you can customize the process:

Handling Image Generation Responses

When image generation is enabled, responses may include image prompts. However, automatic generation behavior differs between methods:
Key Difference: When using chat.completions(), the SDK will detect image prompts but will not automatically generate images or add them to chat history. You must handle this manually. Only chat.send() provides fully automatic image generation and history management.

Image History Management

Image Format in Chat History

Generated images are automatically added to chat history in a structured format:

Managing Image Context

Generated images provide context back to the AI:

Error Handling

Comprehensive Error Handling

Implement robust error handling for image generation:

Graceful Degradation

Handle image generation failures gracefully:

UI Implementation

Complete Image Generation UI

Here’s a complete example of handling image generation in your UI:

CSS for Image Generation UI

Best Practices

Prompt Engineering for Images

Performance Optimization

Content Guidelines

Next Steps

Event System

Master the comprehensive event system for image generation

Auto-Turn Conversations

Combine image generation with natural conversation flow

Tool Calling

Create tools that can generate images programmatically

Media & Vision

Analyze generated images with vision capabilities