# 流式对话请求（Streaming）

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/chat:
    post:
      summary: 流式对话请求（Streaming）
      deprecated: false
      description: Send a chat message with a streaming response.
      tags:
        - 生成对话补全
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  enum:
                    - llama3.2
                  example: llama3.2
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                        example: user
                      content:
                        type: string
                        example: why is the sky blue?
                    required:
                      - role
                      - content
                  example:
                    - role: user
                      content: why is the sky blue?
              required:
                - model
                - messages
      responses:
        '200':
          description: 'A stream of JSON objects is returned:'
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                  created_at:
                    type: string
                  message:
                    type: object
                    properties:
                      role:
                        type: string
                      content:
                        type: string
                      images:
                        type: 'null'
                    required:
                      - role
                      - content
                      - images
                    x-apifox-orders:
                      - role
                      - content
                      - images
                  done:
                    type: boolean
                required:
                  - model
                  - created_at
                  - message
                  - done
                x-apifox-orders:
                  - model
                  - created_at
                  - message
                  - done
              examples:
                '1':
                  summary: Success
                  value:
                    model: llama3.2
                    created_at: '2023-08-04T08:52:19.385406455-07:00'
                    message:
                      role: assistant
                      content: The
                      images: null
                    done: false
                '2':
                  summary: Success
                  value:
                    model: llama3.2
                    created_at: '2023-08-04T19:22:45.499127Z'
                    done: true
                    total_duration: 4883583458
                    load_duration: 1334875
                    prompt_eval_count: 26
                    prompt_eval_duration: 342546000
                    eval_count: 282
                    eval_duration: 4535599000
          headers: {}
          x-apifox-name: Success
        'x-200:Final response:':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                  created_at:
                    type: string
                  done:
                    type: boolean
                  total_duration:
                    type: integer
                  load_duration:
                    type: integer
                  prompt_eval_count:
                    type: integer
                  prompt_eval_duration:
                    type: integer
                  eval_count:
                    type: integer
                  eval_duration:
                    type: integer
                required:
                  - model
                  - created_at
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
                x-apifox-orders:
                  - model
                  - created_at
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
          headers: {}
          x-apifox-name: 'Final response:'
      security: []
      x-apifox-folder: 生成对话补全
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/6041320/apis/api-272428823-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: http://localhost:11434/api/
    description: 正式环境
security: []

```
