> For the complete documentation index, see [llms.txt](https://docs.castmagic.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.castmagic.io/endpoints/generation.md).

# Generation

Run a prompt against a recording and fetch the generated output.

Run a prompt against a recording's transcript to generate AI content, then poll the output for the result. Generation is asynchronous — poll `GET /v1/outputs/:id`, or subscribe a webhook to `output.completed`.

Both endpoints require a **completed transcript** on the recording.

{% hint style="info" %}
**Tier:** `automation`. Base URL `https://app.castmagic.io`.
{% endhint %}

## Generate an output

<mark style="color:green;">`POST`</mark> `https://app.castmagic.io/v1/recordings/:id/generate`

Pass `prompt_id` to run a saved custom prompt (from [`GET /v1/prompts`](/endpoints/prompts.md)), **or** `prompt` to run one-off text. Provide exactly one.

#### Request Body

| Name       | Type   | Description                                      |
| ---------- | ------ | ------------------------------------------------ |
| prompt\_id | String | ID of a custom prompt in the recording's space   |
| prompt     | String | One-off prompt text (alternative to `prompt_id`) |
| name       | String | Optional name for a one-off prompt               |

{% hint style="info" %}
Only **custom** prompts can be run via the API. The built-in fan-out system prompts (overview, quotes, and so on) run through automatic generation, not this endpoint.
{% endhint %}

{% tabs %}
{% tab title="202: Accepted" %}

```json
{
    "output_id": "o1...",
    "output_type": "dynamic",
    "prompt_id": "p1...",
    "status": "queued"
}
```

{% endtab %}

{% tab title="400: Bad Request Transcript not ready" %}

```json
{ "error": "transcript is not ready (status: processing); generation needs a completed transcript" }
```

{% endtab %}
{% endtabs %}

## Fetch an output

<mark style="color:blue;">`GET`</mark> `https://app.castmagic.io/v1/outputs/:id`

One generated output with its text. Statuses are `queued`, `retrying`, `completed`, `failed`, and `canceled`.

{% tabs %}
{% tab title="200: OK" %}

```json
{
    "output": {
        "id": "o1...",
        "type": "dynamic",
        "status": "completed",
        "created_at": "2026-08-21T22:05:00Z",
        "text": "Here's your LinkedIn post...",
        "recording_id": "e1..."
    }
}
```

{% endtab %}

{% tab title="404: Not Found" %}

```json
{ "error": "Output not found: o1..." }
```

{% endtab %}
{% endtabs %}
