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

# Public agent chat (NDJSON stream)

> One JSON event per line; assemble the reply from event.text. The agent owner is billed for the turn. Pass a salted client hash for per-visitor rate limiting (never a raw IP). 429 when rate limited.



## OpenAPI

````yaml /openapi.json post /v1/agent/{agentId}/chat
openapi: 3.1.0
info:
  title: Syvon API
  version: 1.0.0
  description: >-
    Two client-facing surfaces: the Portal management plane (syvon.ai/api/*,
    portal JWT) and the Brain read plane (brain.syvon.ai/v1/*, workspace key
    sk_ws_…). Schemas are generated from the @syvon/sdk TypeScript types — the
    shipped .d.ts files are the authoritative contract.
servers:
  - url: https://syvon.ai
    description: Portal (management plane)
  - url: https://brain.syvon.ai
    description: Brain (read plane)
security: []
tags:
  - name: Auth
    description: Minting the portal JWT
  - name: Portal
    description: Management plane — user-scoped (portal JWT)
  - name: Brain
    description: Published-agent read plane — workspace-scoped (sk_ws_…)
paths:
  /v1/agent/{agentId}/chat:
    post:
      tags:
        - Brain
      summary: Public agent chat (NDJSON stream)
      description: >-
        One JSON event per line; assemble the reply from event.text. The agent
        owner is billed for the turn. Pass a salted client hash for per-visitor
        rate limiting (never a raw IP). 429 when rate limited.
      operationId: chat
      parameters:
        - name: agentId
          in: path
          required: true
          description: Project (agent) id
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
      responses:
        '200':
          description: NDJSON stream of ChatStreamEvent, one per line
          content:
            application/x-ndjson:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChatStreamEvent'
        '429':
          description: Rate limited — back off
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
      security:
        - workspaceKeyAuth: []
      servers:
        - url: https://brain.syvon.ai
components:
  schemas:
    ChatRequest:
      type: object
      description: ''
      properties:
        prompt:
          description: ''
          type: string
        client:
          description: Salty hash identifying the visitor (for per-visitor rate limiting).
          type: string
        threadKey:
          description: Conversation thread id (resumes a thread server-side).
          type: string
        history:
          description: Preceding turns, oldest first.
          type: array
          items:
            type: object
            properties:
              role:
                description: ''
                type: string
                enum:
                  - user
                  - assistant
              content:
                description: ''
                type: string
            required:
              - role
              - content
        section:
          description: A page/section id the wrapper scopes the answer to.
          type: string
        brandSlug:
          description: Brand slug override.
          type: string
      required:
        - prompt
    ChatStreamEvent:
      type: object
      description: A single line from the NDJSON chat stream. Discriminated by `type`.
      properties:
        type:
          description: ''
          type: string
        text:
          description: Text fragment (for token/delta events).
          type: string
        content:
          description: Full accumulated text on completion (some events).
          type: string
        message:
          description: ''
          type: string
      required:
        - type
      additionalProperties: true
  securitySchemes:
    workspaceKeyAuth:
      type: http
      scheme: bearer
      description: Workspace API key (sk_ws_…)

````