---
title: "Generate an agent draft from a task, streaming its work"
method: POST
path: "/table-enrichments/saved-agents/generate/stream/"
tags: ["table-enrichments"]
---

# Generate an agent draft from a task, streaming its work

`POST /table-enrichments/saved-agents/generate/stream/`

## Request

- Base URL: `https://api.getoneprofile.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getoneprofile.ai/table-enrichments/saved-agents/generate/stream/`
- Auth: HTTP bearer

Expand a natural-language task into a complete agent draft (a structured prompt with {{input}} placeholders, a name and icon, typed output fields and sample test cases), streamed as Server-Sent Events. The first frame is `turn`, carrying the `generation_id` a Stop is sent to; then a `step` frame for each thing the builder actually did (`read_context` when the workspace has written its business context, `write_instructions`, `choose_outputs`, `write_examples`, `finish`), each with its measured duration; then one `result` frame with the draft.

Failures arrive as an `error` frame, because the stream has already answered 200: reason `limit` or `paused` when the workspace's daily AI Assistant allowance refused the build, `stopped` when the caller stopped it, and no reason for anything else. Counts against the allowance; a stopped or failed build gives its turn back.

Closing the connection does not stop the build; the Stop route does.

## Request body

- SavedAgentGenerateRequestSchema: A natural-language task to expand into a full agent draft.
  - `reference_material` string, nullable: Text from files the user attached to the builder, concatenated. Folded into prompt generation so the draft reflects their own rubric or guide.
  - `task_description` string, required

## Response `200`

A stream of Server-Sent Events; the final `result` frame's `data` is the generated draft.

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `422`: Invalid request made to the API.
- `500`: Internal server error.
- `502`: Bad gateway error.
- `503`: Service unavailable.

---

[API](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile.md) · [All operations](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/llms.txt) · [OpenAPI document](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/revisions/4a6bd71e3f02?raw)
