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

# 生成会话洞察

> 按需触发生成会话洞察。

如果洞察已生成，则返回 ``already_exists``。
否则会在后台启动生成。生成完成后，轮询
GET 洞察端点以获取结果。

<Note>
  `devin_id` 是以前缀 `devin-` 开头的会话 ID (例如：`devin-abc123`) 。
</Note>

<div id="permissions">
  ## 权限
</div>

需要具有企业级 `ManageAccountSessions` 权限的服务用户。

<div id="behavior">
  ## 行为
</div>

* 如果洞察已生成 (或正在生成) ，端点会返回 `{ "status": "already_exists" }`，不会再次触发生成。
* 如果不存在洞察 (或上一次尝试失败) ，端点会在后台触发生成，并返回 `{ "status": "started" }`。
* 轮询 [GET 会话洞察](/zh/api-reference/v3/sessions/get-enterprise-session-insights) 端点，以在生成完成后获取结果。


## OpenAPI

````yaml zh/v3-openapi.yaml POST /v3/enterprise/sessions/{devin_id}/insights/generate
openapi: 3.1.0
info:
  description: 采用 Service User 身份验证和 RBAC 的 Devin v3 API
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/enterprise/sessions/{devin_id}/insights/generate:
    post:
      tags:
        - sessions
      summary: 生成会话洞察
      description: |-
        按需触发生成会话洞察。

        如果洞察已生成，则返回 ``already_exists``。
        否则会在后台启动生成。生成完成后，轮询
        GET 洞察端点以获取结果。
      operationId: >-
        handle_generate_account_session_insights_v3_enterprise_sessions__devin_id__insights_generate_post
      parameters:
        - description: Devin 会话 ID（前缀：devin-）
          in: path
          name: devin_id
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            example: devin-abc123def456
            title: Devin Id
        - in: query
          name: org_id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Org Id
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionInsightsGenerateResponse'
          description: 成功响应
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: 验证错误
components:
  schemas:
    SessionInsightsGenerateResponse:
      description: 触发生成会话洞察后返回的响应。
      properties:
        session_id:
          description: 触发生成洞察的会话 ID。
          title: Session Id
          type: string
        status:
          description: 生成请求的状态。
          title: Status
          type: string
      required:
        - session_id
        - status
      title: SessionInsightsGenerateResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    bearerAuth:
      description: 服务用户凭据（前缀：cog_）
      scheme: bearer
      type: http

````