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

# Stream Agent Build

> Stream Agent Build with the DialNexa API. Streams build progress as newline-delimited JSON and returns the generated draft configuration without saving or publishing an agent.

<span data-api-safety-label="read-only"><Badge color="gray" size="sm" shape="pill">Read only</Badge></span>

Stream Agent Build uses your workspace API key. Streams build progress as newline-delimited JSON and returns the generated draft configuration without saving or publishing an agent.

## Before you begin

Use a server-side [API key](/docs/api-reference/authentication) for the intended workspace.

## Stream Agent Build request

The request panel lists supported query parameters and body fields. For a request body, the example below supplies the required fields. Replace sample values with your own inputs.

```bash theme={null}
curl --request POST 'https://api.dialnexa.com/v1/agent-builder/run/stream' \
  --header "Authorization: Bearer $DIALNEXA_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "structured_input": {
    "company_and_offering": {
      "description": "Company and offering",
      "value": "Acme provides appointment scheduling software."
    },
    "target_customer": {
      "description": "Target customer",
      "value": "Small business owners who requested a demo."
    },
    "primary_goal": {
      "description": "Call goal",
      "value": "Arrange a product demo."
    },
    "success_criteria": {
      "description": "Success criteria",
      "value": "Confirm interest and a preferred callback time."
    },
    "information_to_collect": {
      "description": "Information to collect",
      "value": "Name and preferred callback time."
    },
    "objections_and_faqs": {
      "description": "Questions",
      "value": "Explain that the demo is free."
    },
    "agent_tone": {
      "description": "Tone",
      "value": "Friendly, concise, and professional."
    },
    "additional_context": {
      "description": "Context",
      "value": "Do not promise pricing or unavailable appointment slots."
    }
  }
}'
```

## Verify the result

Expect HTTP `200` with `Content-Type: application/x-ndjson`. Parse complete lines as JSON. A `complete` event contains `data`; an `error` event can arrive after HTTP headers have already been sent. There is no success envelope around the stream.

Progress events include `phase_start`, `phase_complete`, `thinking_delta`, and `building_event`. The final result includes `status`, `missingQuestions`, `evaluation`, and `draftAgent`. A completed stream is not proof that an agent was saved.

This operation also accepts the matching `/v1/assistant` path. The request and result contracts are shared. Use one path consistently for your integration.

## Retry safety

This operation does not modify workspace resources. Retry after a transient connection failure.

## Errors and recovery

* `401`: Missing, expired, or invalid API key.

## Related endpoints

* [Get Agent Builder Inventory](/docs/api-reference/v1/agent-builder/inventory)
* [Build Agent Configuration](/docs/api-reference/v1/agent-builder/run)
* [Generate Agent Objectives](/docs/api-reference/v1/agent-builder/generate-objectives)
* [Generate Agent Tone](/docs/api-reference/v1/agent-builder/generate-tone)
* [API authentication](/docs/api-reference/authentication)


## OpenAPI

````yaml POST /v1/agent-builder/run/stream
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
paths:
  /v1/agent-builder/run/stream:
    post:
      tags:
        - Agent Builder
      summary: Stream Agent Build
      description: >-
        Streams build progress as newline-delimited JSON and returns the
        generated draft configuration without saving or publishing an agent.
      operationId: streamAgentBuilder
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunAgentBuilder'
            examples:
              request:
                value:
                  structured_input:
                    company_and_offering:
                      description: Company and offering
                      value: Acme provides appointment scheduling software.
                    target_customer:
                      description: Target customer
                      value: Small business owners who requested a demo.
                    primary_goal:
                      description: Call goal
                      value: Arrange a product demo.
                    success_criteria:
                      description: Success criteria
                      value: Confirm interest and a preferred callback time.
                    information_to_collect:
                      description: Information to collect
                      value: Name and preferred callback time.
                    objections_and_faqs:
                      description: Questions
                      value: Explain that the demo is free.
                    agent_tone:
                      description: Tone
                      value: Friendly, concise, and professional.
                    additional_context:
                      description: Context
                      value: Do not promise pricing or unavailable appointment slots.
      responses:
        '200':
          description: NDJSON stream of thinking updates and final result
          content:
            application/x-ndjson:
              schema:
                type: string
                description: >-
                  One JSON object per line. Event types: phase_start,
                  phase_complete, thinking_delta, building_event, complete,
                  error. The complete event contains data with status, events,
                  missingQuestions, evaluation, draftAgent, promptText,
                  welcomeMessage, technicalProfile, and error.
              example: >
                {"type":"phase_start","phase":"thinking"}

                {"type":"thinking_delta","delta":"Reading your
                requirements","label":"Understanding your
                needs","phase":"thinking"}
        '401':
          description: Missing, expired, or invalid API key.
      security:
        - bearer: []
components:
  schemas:
    RunAgentBuilder:
      type: object
      properties:
        structured_input:
          description: >-
            Structured blueprint submission - each field has a description
            (field guidance) and value (user answer)
          allOf:
            - $ref: '#/components/schemas/StructuredBlueprintInput'
        build_attempt:
          type: number
          description: >-
            Build attempt number (1-2). Validation runs only on attempt 1;
            attempt 2 skips re-validation.
          minimum: 1
          maximum: 2
          default: 1
        pipeline:
          type: string
          description: >-
            Engine for the generated agent. "s2s" builds the realtime pipeline
            on the same single-prompt agent; anything else builds the cascaded
            pipeline.
          enum:
            - cascaded
            - s2s
          default: cascaded
        target_shape:
          type: string
          description: >-
            Kind of agent to build. "cfa" writes a conversation-flow document (a
            step graph), "ivr" writes a touch-tone menu; anything else builds a
            single-prompt agent.
          enum:
            - spa
            - cfa
            - ivr
          default: spa
      required:
        - structured_input
    StructuredBlueprintInput:
      type: object
      properties:
        company_and_offering:
          $ref: '#/components/schemas/StructuredBlueprintField'
        target_customer:
          $ref: '#/components/schemas/StructuredBlueprintField'
        primary_goal:
          $ref: '#/components/schemas/StructuredBlueprintField'
        success_criteria:
          $ref: '#/components/schemas/StructuredBlueprintField'
        information_to_collect:
          $ref: '#/components/schemas/StructuredBlueprintField'
        objections_and_faqs:
          $ref: '#/components/schemas/StructuredBlueprintField'
        agent_tone:
          $ref: '#/components/schemas/StructuredBlueprintField'
        additional_context:
          $ref: '#/components/schemas/StructuredBlueprintField'
        validation_clarifications:
          $ref: '#/components/schemas/StructuredBlueprintField'
      required:
        - company_and_offering
        - target_customer
        - primary_goal
        - success_criteria
        - information_to_collect
        - objections_and_faqs
        - agent_tone
        - additional_context
    StructuredBlueprintField:
      type: object
      properties:
        description:
          type: string
          description: User-facing explanation of what this field is asking for
          example: >-
            Share your company name and a short description of your product,
            service, or industry.
        value:
          type: string
          description: User-provided answer for this field
          example: Acme Corp - we sell B2B payroll software for mid-market HR teams.
      required:
        - description
        - value
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````