> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elumenta.ru/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Generation

> The single unified endpoint for all AI generation types

## Overview

`POST /api/v2/generate` is the **one endpoint** for all AI generation — text, images, video, audio, TTS, music. The model slug determines what gets generated and what `params` are accepted.

<ParamField header="Authorization" type="string" required>
  `Authorization: Bearer nb_YOUR_API_KEY`
</ParamField>

<ParamField body="model" type="string" required>
  Model slug. See [Model Catalog](/en/resources/models-catalog) for all available slugs.
</ParamField>

<ParamField body="prompt" type="string" required>
  The prompt or input text. For text models: the user message. For image/video: the visual description.
</ParamField>

<ParamField body="params" type="object" default="{}">
  Model-specific parameters. Examples below by category.
</ParamField>

## Text Generation

```json theme={null}
{
  "model": "claude-sonnet-4.5",
  "prompt": "Write a product description for wireless headphones",
  "params": {
    "system_prompt": "You are a professional copywriter.",
    "temperature": 0.7,
    "max_tokens": 500,
    "messages": [
      {"role": "user", "content": "Previous message for multi-turn context"}
    ]
  }
}
```

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://elumenta.ru/api/v2/generate \
    -H "Authorization: Bearer nb_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-4.5",
      "prompt": "Write a product description for wireless headphones",
      "params": {
        "system_prompt": "You are a professional copywriter.",
        "temperature": 0.7
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  res = requests.post(
      "https://elumenta.ru/api/v2/generate",
      headers={"Authorization": "Bearer nb_YOUR_API_KEY"},
      json={
          "model": "claude-sonnet-4.5",
          "prompt": "Write a product description for wireless headphones",
          "params": {"system_prompt": "You are a professional copywriter.", "temperature": 0.7}
      }
  )
  print(res.json()["result_text"])
  ```
</CodeGroup>

## Image Generation

```json theme={null}
{
  "model": "flux-1.1-pro",
  "prompt": "Portrait of a CEO in a modern office, professional photography",
  "params": {
    "negative_prompt": "blurry, watermark, text",
    "size": "1024x1024",
    "format": "webp",
    "seed": 42
  }
}
```

Common image `params`:

| Param             | Type    | Description                               |
| ----------------- | ------- | ----------------------------------------- |
| `size`            | string  | e.g. `1024x1024`, `1024x1792`, `768x1344` |
| `format`          | string  | `webp` (default), `png`, `jpeg`           |
| `quality`         | string  | `standard` or `hd` (DALL-E 3, GPT Image)  |
| `negative_prompt` | string  | What to exclude (Flux, SD models)         |
| `seed`            | integer | For reproducible results                  |
| `aspect_ratio`    | string  | e.g. `16:9`, `9:16` (Midjourney)          |

## Video Generation

```json theme={null}
{
  "model": "kling-v2.1-pro",
  "prompt": "A drone flyover of a futuristic city at night, cinematic",
  "params": {
    "duration": 5,
    "aspect_ratio": "16:9",
    "image_url": "https://example.com/start-frame.jpg"
  }
}
```

<Note>
  Video generations return `status: "pending"`. Poll `GET /api/v2/generate/{id}` for the result.
</Note>

## TTS / Voice

```json theme={null}
{
  "model": "elevenlabs-v2",
  "prompt": "Welcome to Elumenta. Your AI-powered creative studio.",
  "params": {
    "voice_id": "rachel",
    "speed": 1.0,
    "format": "mp3"
  }
}
```

## Response

<ResponseField name="id" type="integer">
  Generation ID (integer). Use for polling: `GET /api/v2/generate/{id}`
</ResponseField>

<ResponseField name="status" type="string">
  `completed` | `pending` | `failed`
</ResponseField>

<ResponseField name="model_slug" type="string">
  The model used.
</ResponseField>

<ResponseField name="result_text" type="string | null">
  Text output. Present for LLM, STT, and tool responses.
</ResponseField>

<ResponseField name="result_url" type="string | null">
  File URL. Present for image, video, audio, and TTS responses.
</ResponseField>

<ResponseField name="thumbnail_url" type="string | null">
  Thumbnail URL for video results.
</ResponseField>

<ResponseField name="error" type="string | null">
  Error message if `status` is `failed`.
</ResponseField>

<ResponseField name="tokens_spent" type="integer">
  Elumenta tokens deducted. Zero if failed.
</ResponseField>

<ResponseField name="processing_ms" type="integer">
  Processing time in milliseconds.
</ResponseField>

<ResponseField name="result_metadata" type="object | null">
  Additional data: `width`, `height` for images; `duration` for video/audio; etc.
</ResponseField>

## Response Example — Text

```json theme={null}
{
  "id": 18473,
  "status": "completed",
  "model_slug": "claude-sonnet-4.5",
  "result_text": "Introducing our Premium Wireless Headphones...",
  "result_url": null,
  "thumbnail_url": null,
  "error": null,
  "tokens_spent": 3,
  "processing_ms": 2104,
  "result_metadata": null
}
```

## Response Example — Image

```json theme={null}
{
  "id": 18491,
  "status": "completed",
  "model_slug": "flux-1.1-pro",
  "result_text": null,
  "result_url": "https://storage.elumenta.ru/generations/18491.webp",
  "thumbnail_url": null,
  "tokens_spent": 8,
  "processing_ms": 6840,
  "result_metadata": {
    "width": 1024,
    "height": 1024
  }
}
```

## Response Example — Pending (Video)

```json theme={null}
{
  "id": 18502,
  "status": "pending",
  "model_slug": "kling-v2.1-pro",
  "result_text": null,
  "result_url": null,
  "tokens_spent": 0,
  "processing_ms": null,
  "result_metadata": null
}
```
