---
title: "Generation task"
manual: "Ai3 Core"
version: "main"
permalink: "https://docs.typo3.org/permalink/wegewerk/ai3_core:developer-generation-task@main"
source: "Developer/GenerationTask.rst"
rendered: "2026-10-23T16:30:49+00:00"
---

# Generation task {#developer-generation-task}

A `GenerationTask` represents one AI-generation request. Tasks are
stored in the database table `tx_ai3_domain_model_generation_task`
and managed through the Extbase `GenerationTaskRepository`.

## Task lifecycle {#developer-generation-task-status}

Every task moves through a set of states defined by
`\Wegewerk\Ai3Core\Enums\Status`:

| Value | Meaning |
| --- | --- |
| `Pending` | Task created, waiting to be processed. |
| `Processing` | Reserved for future use (processing flag). |
| `Done` | AI generation completed; `result` is populated. |
| `Failed` | Generation failed; `error_message` is populated. |
| `Canceled` | Task was canceled before processing. |

## Field reference {#developer-generation-task-fields}

-   **status**

    -   *Type:* string (enum)
    -   *Default:* `Pending`

    Current lifecycle state. One of `Pending`, `Processing`,
    `Done`, `Failed`, `Canceled`.

-   **prompt**

    -   *Type:* string
    -   *Default:* *(empty)*

    The text prompt sent to the AI endpoint.

-   **image**

    -   *Type:* string
    -   *Default:* *(empty)*

    Optional path to an image passed to the capability endpoint.

-   **capability**

    -   *Type:* string
    -   *Default:* *(empty)*

    Key of the registered capability (e.g. `my_ext_summary`).
    See [Capability API](https://docs.typo3.org/permalink/wegewerk/ai3_core:developer-capability-api@main).

-   **record_table**

    -   *Type:* string
    -   *Default:* *(empty)*

    Name of the TYPO3 database table that owns the record being
    processed (e.g. `tt_content`).

-   **record_field**

    -   *Type:* string
    -   *Default:* *(empty)*

    Name of the field within `record_table` that will receive the
    generated text.

-   **record_uid**

    -   *Type:* int

    UID of the owning record.

-   **generate_language**

    -   *Type:* string
    -   *Default:* *(empty)*

    ISO language code passed to the capability endpoint.

-   **result**

    -   *Type:* string
    -   *Default:* *(empty)*

    The text returned by the capability endpoint after a successful
    generation.

-   **result_meta**

    -   *Type:* string
    -   *Default:* *(empty)*

    Optional JSON metadata returned alongside the result.

-   **error_message**

    -   *Type:* string
    -   *Default:* *(empty)*

    Human-readable error description when `status` is `Failed`.

-   **reviewed**

    -   *Type:* bool
    -   *Default:* `false`

    Set to `true` by an editor after reviewing the generated result.

-   **generated_timestamp**

    -   *Type:* int (Unix timestamp)
    -   *Default:* `0`

    Unix timestamp set when generation completes successfully.

## GenerationTaskService {#developer-generation-task-service}

`\Wegewerk\Ai3Core\Service\GenerationTaskService` is the primary
API for working with the task queue. Inject it via constructor:

**Adding a generation task**

```php
use Wegewerk\Ai3Core\Domain\Model\Dto\AddGenerationTask;
use Wegewerk\Ai3Core\Service\GenerationTaskService;

$dto = new AddGenerationTask(
    status: 'Pending',
    prompt: 'Write a short product description.',
    image: '',
    capability: 'my_ext_summary',
    record_table: 'tt_content',
    record_field: 'bodytext',
    record_uid: 42,
    generateLanguage: 'en',
    parameters: '',
    result: '',
    result_meta: '',
    error_message: '',
);

$task = $this->generationTaskService->addTask($dto);
```

Useful query methods:

| Method | Description |
| --- | --- |
| `getTask(int $uid)` | Latest task for `record_uid`. |
| `isTaskRunning(int $uid)` | `true` if status is Pending or Processing. |
| `hasGenerationDone(int $uid)` | `true` if the latest task is Done. |
| `getLatestResult(int $uid)` | Result string of the most recent Done task. |
| `isReviewed(int $uid)` | `true` if the latest task has been reviewed. |
| `setReviewed(GenerationTask $task)` | Marks the task as reviewed and persists. |
