# Run an agent generation

> Sends messages to the agent, resolves its tools, and runs the AI model loop. Background by default: returns `202 Accepted` with a `generation_id` to poll via `GET /api/v1/generations/{generation_id}`. Pass `?wait=true` to block and receive the result inline, where client tools pause the generation and return `requires_action`. Streaming (`stream: true`) implies waiting.

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Run an agent generation"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/api/v1/agents/{agent_id}/generate"}
  context={"endpoint"}
>
  
</MethodEndpoint>

Sends messages to the agent, resolves its tools, and runs the AI model loop. Background by default: returns `202 Accepted` with a `generation_id` to poll via `GET /api/v1/generations/{generation_id}`. Pass `?wait=true` to block and receive the result inline, where client tools pause the generation and return `requires_action`. Streaming (`stream: true`) implies waiting.

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
>
  <Translate id="theme.openapi.request.title">Request</Translate>
</Heading>

<ParamsDetails
  {...require("./create-agent-generation.ParamsDetails.json")}
>
  
</ParamsDetails>

<RequestSchema
  {...require("./create-agent-generation.RequestSchema.json")}
>
  
</RequestSchema>

<StatusCodes
  {...require("./create-agent-generation.StatusCodes.json")}
>
  
</StatusCodes>
