# Expected Response Structure for generate_images_from_prompts

## Function Flow

1. **Frontend calls**: `POST /v1/writer/images/generate_images/` with `{ ids: [1, 2, 3] }`
2. **Backend ViewSet** (`ImagesViewSet.generate_images`):
   - Calls `run_ai_task` with `function_name='generate_images_from_prompts'`
   - Returns response with `queued_prompts` if in TEST MODE

3. **AIEngine.execute**:
   - Validates, prepares, builds prompt (placeholder), parses (placeholder)
   - Calls `save_output` which queues prompts (TEST MODE)

4. **GenerateImagesFromPromptsFunction.save_output**:
   - Returns dict with queued prompts

## Response Structure (TEST MODE)

```json
{
  "success": true,
  "count": 3,
  "images_generated": 0,
  "images_failed": 0,
  "total_images": 3,
  "queued_prompts": [
    {
      "image_id": 1,
      "index": 1,
      "image_type": "featured_image",
      "content_title": "Your Content Title",
      "provider": "openai",
      "model": "dall-e-2",
      "formatted_prompt": "Create a high-quality realistic image to use as a featured photo for a blog post titled \"Your Content Title\". The image should visually represent the theme, mood, and subject implied by the image prompt: [original prompt]. Focus on a realistic, well-composed scene that naturally communicates the topic without text or logos...",
      "negative_prompt": null,
      "prompt_length": 250
    },
    {
      "image_id": 2,
      "index": 2,
      "image_type": "in_article_1",
      "content_title": "Your Content Title",
      "provider": "openai",
      "model": "dall-e-2",
      "formatted_prompt": "...",
      "negative_prompt": null,
      "prompt_length": 245
    }
  ],
  "test_mode": true,
  "provider": "openai",
  "model": "dall-e-2",
  "errors": null
}
```

## Response Structure (Production Mode - when AI calls are enabled)

```json
{
  "success": true,
  "count": 3,
  "images_generated": 3,
  "images_failed": 0,
  "total_images": 3,
  "errors": null
}
```

## Key Points

1. **TEST MODE** (current):
   - `images_generated: 0` (no actual images generated)
   - `queued_prompts` array contains all formatted prompts
   - `test_mode: true`
   - Each prompt includes the complete formatted prompt that would be sent to AI

2. **Production MODE** (when AI calls are uncommented):
   - `images_generated` will be > 0
   - `queued_prompts` will not be in response
   - `test_mode: false` or not present
   - Images will have `image_url` and `status='generated'`

## Console Logging

The function logs to console (if DEBUG_MODE=True):
- `[generate_images_from_prompts] [TEST MODE] Queued prompt X/Y`
- `[generate_images_from_prompts] [TEST MODE] Provider: openai, Model: dall-e-2`
- `[generate_images_from_prompts] [TEST MODE] Prompt length: 250 chars`
- `[generate_images_from_prompts] [TEST MODE] Prompt preview: ...`

## Frontend Console Output

When clicking "Generate Images", browser console will show:
```
[Generate Images] Request: { imageIds: [1, 2, 3], count: 3 }
[Generate Images] Endpoint: /v1/writer/images/generate_images/
[Generate Images] Full Response: { success: true, queued_prompts: [...], ... }
[Generate Images] Queued Prompts (TEST MODE - NOT sent to AI): [...]
[Generate Images] Provider: openai, Model: dall-e-2
[Generate Images] Prompt 1/3:
  - Image Type: featured_image
  - Content: "Your Content Title"
  - Prompt Length: 250 chars
  - Full Prompt: "Create a high-quality realistic image..."
```

