> For the complete documentation index, see [llms.txt](https://sonic-ai-works.gitbook.io/sonic-networks-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sonic-ai-works.gitbook.io/sonic-networks-docs/api-reference/generation-operations.md).

# Generation operations

> **MVP note:** exact endpoint names and request/response payloads remain subject to versioned API evolution. The lifecycle invariants below are the durable contract that implementations must preserve.

The canonical lifecycle for generation and Upload & Cover is:

`request → validate → idempotent operation → reserve → dispatch → callback merge → completed | failed → settle | refund`

## Illustrative API references

These routes are examples until backed by the released OpenAPI specification:

```
POST /generations
POST /cover
```

## Dispatch preconditions

* tenant/auth context is valid;
* input schema is valid;
* URL inputs pass public-URL validation;
* required credit amount is resolved in atomic units;
* the idempotent operation exists;
* credit reservation succeeds.

## Operation identity

Store the provider job identifier as an **external correlation value**, not as the platform's sole business identity. The SONIC operation/idempotency identity remains the durable retry boundary.

## Callback progression

Callback stages may arrive out of order or with partial track fields. Merge by stable track identity and stage monotonicity. Never overwrite a completed/non-null result with an earlier or partial callback.

## Terminal financial behavior

A completed provider result can settle the reservation exactly once. A terminal provider failure/cancellation releases or refunds it exactly once. Ledger retries must not redispatch provider work.

## Reference checklist

Every generation endpoint should state:

* required auth and tenant scope;
* idempotency-key behavior;
* reservation amount, currency/token, and decimals;
* URL validation requirements for remote assets;
* provider correlation identifiers;
* callback stages and merge behavior;
* terminal settle/refund semantics;
* safe retry rules.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sonic-ai-works.gitbook.io/sonic-networks-docs/api-reference/generation-operations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
