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

# Generate Editor Assistant

> Stream AI-generated questions/blocks for the editor assistant.

Streams SSE events:
- type: "message" - AI's explanation text
- type: "question" - A generated question
- type: "block" - A block header (form mode only)
- type: "form_metadata" - Form name/description update (form mode only)
- type: "template_metadata" - Template name update (template mode only)
- type: "done" - Generation complete
- type: "error" - An error occurred



## OpenAPI

````yaml post /ai/editor-assistant/generate
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /ai/editor-assistant/generate:
    post:
      tags:
        - provider
        - ai
      summary: Generate Editor Assistant
      description: |-
        Stream AI-generated questions/blocks for the editor assistant.

        Streams SSE events:
        - type: "message" - AI's explanation text
        - type: "question" - A generated question
        - type: "block" - A block header (form mode only)
        - type: "form_metadata" - Form name/description update (form mode only)
        - type: "template_metadata" - Template name update (template mode only)
        - type: "done" - Generation complete
        - type: "error" - An error occurred
      operationId: generate_editor_assistant_ai_editor_assistant_generate_post
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EditorAssistantRequest'
        required: true
      responses:
        '200':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    EditorAssistantRequest:
      properties:
        mode:
          type: string
          enum:
            - template
            - form
          title: Mode
          description: >-
            Editor mode: 'template' for note templates, 'form' for check-in
            forms
        message:
          type: string
          title: Message
          description: User's natural language instruction
        currentState:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Currentstate
          description: Serialized current editor state
        history:
          anyOf:
            - items:
                $ref: '#/components/schemas/ConversationMessage'
              type: array
            - type: 'null'
          title: History
          description: Conversation history
        files:
          anyOf:
            - items:
                $ref: '#/components/schemas/FileAttachment'
              type: array
            - type: 'null'
          title: Files
          description: PDF/image uploads (base64)
      type: object
      required:
        - mode
        - message
      title: EditorAssistantRequest
      description: Request schema for the AI editor assistant endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ConversationMessage:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
          description: Role of the message sender
        content:
          type: string
          title: Content
          description: Message content
        timestamp:
          anyOf:
            - type: string
            - type: 'null'
          title: Timestamp
          description: Message timestamp
        files:
          anyOf:
            - items:
                $ref: '#/components/schemas/FileAttachment'
              type: array
            - type: 'null'
          title: Files
          description: File attachments (images, documents, etc.)
      type: object
      required:
        - role
        - content
      title: ConversationMessage
      description: A single message in a conversation with an AI.
    FileAttachment:
      properties:
        name:
          type: string
          title: Name
          description: File name
        size:
          type: integer
          title: Size
          description: File size in bytes
        type:
          type: string
          title: Type
          description: MIME type
        data:
          type: string
          title: Data
          description: Base64 encoded file data
      type: object
      required:
        - name
        - size
        - type
        - data
      title: FileAttachment
      description: File attachment schema.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````