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

# Creating Agents

> Create, update, duplicate, and delete agent templates through the API.

You can now create and maintain agents directly from the public API.

## Endpoints

* [POST /agent/create](/api/agents/post-agent-create) creates a new agent.
* [POST /agent/{agent_id}/update](/api/agents/post-agent-update) updates metadata and mutates graph structure.
* [POST /agent/{agent_id}/duplicate](/api/agents/post-agent-duplicate) duplicates an agent and returns its copied graph payload.
* [POST /agent/{agent_id}/delete](/api/agents/post-agent-delete) soft-deletes an agent.

## Generation Agents

For AI Avatar, Video Generation, Audio Generation, and Image Generation, create a metadata-only agent with `POST /agent/create`, then add the generation node with `POST /agent/{agent_id}/update`.

Generation-only agents do not need Video Input nodes. Run them with `POST /agent/{agent_id}/run` and no video inputs.

See [Run Agent](/api/agent-runs/post-agent-run#generation-only-workflows) for generation-only run examples.

## Agent Graph Model

Graph mutations happen via `POST /agent/{agent_id}/update` using ordered `operations` with create/update/delete node/connection steps.

In this contract:

* Node params are validated server-side using tile metadata and node schemas.
* Position is backend-managed (auto-layout), not client-managed.
* Agent node responses are represented as `agent_node_id`, `node_type`, and `params_used` (`node_type` contains `node_type_id` and docs metadata).
* New nodes in `create_node` operations can only use request-scoped `temp_ref_id`; persisted `agent_node_id` values are backend-generated and returned in the response.
* `temp_ref_id` values are never persisted and only work within the single update request where they are created.

## Optional Dashboard Flow

You can still create agents in [edit.mosaic.so](https://edit.mosaic.so) and use the API to run them.

## Next Steps

* Use [GET /agent/\[agent\_id\]](/api/agents/get-agent) to inspect your template
* Use [POST /agent/\[agent\_id\]/duplicate](/api/agents/post-agent-duplicate) to clone an existing template graph
* Use [POST /agent/\[agent\_id\]/update](/api/agents/post-agent-update) for both metadata and graph mutations
* Use [POST /agent/\[agent\_id\]/run](/api/agent-runs/post-agent-run) to execute it
* Use [GET /node\_types](/api/agent-nodes/get-agent-nodes) to discover available node types
