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

# 训练智能体

<Note>
  你可以通过智能体训练接口向指定智能体添加训练文件（支持批量上传）进行智能体训练。
  响应数据和创建智能体一样，略。
</Note>

### cURL 请求示例

```bash theme={null}
curl --location --request PATCH 'https://geekai.co/api/v1/agent/be9062c1-68d5-48ee-b74e-fab6d864bc29/embed' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--form 'embed_files=@"/E:/文档/极客智坊/训练文件1.txt"' \
--form 'embed_files=@"/E:/文档/极客智坊/训练文件2.txt"' \
--form 'embed_files=@"/E:/文档/极客智坊/训练文件3.txt"'
```

### Postman 请求响应示例

<img src="https://static.geekai.co/storage/2024/07/14/image-20240420020516665.png" className="mt-2" alt="训练智能体" />


## OpenAPI

````yaml openapi.yaml PATCH /agent/{uuid}/embed
openapi: 3.1.0
info:
  title: GeekAI API Docs
  description: >-
    GeekAI API Specification Document Provides AI capabilities such as chat,
    image generation, speech processing, video generation, ai agents and file
    extract.
  version: 1.0.0
servers:
  - url: https://geekai.dev/api/v1
    description: base URL
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /agent/{uuid}/embed:
    patch:
      tags:
        - Agent
      summary: Embed Agent Knowledge
      description: Embed local training files into the specified agent's knowledge base.
      operationId: embedAgentKnowledge
      parameters:
        - $ref: '#/components/parameters/UuidParam'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - embed_files
              properties:
                embed_files:
                  type: array
                  description: local training files
                  items:
                    type: string
                    format: binary
                  example:
                    - /E:/Documents/file.pdf
      responses:
        '200':
          description: successful response
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                  - data
                properties:
                  message:
                    type: string
                    description: response message
                    example: File uploaded successfully, processing in progress.
                  data:
                    type: object
                    properties:
                      task_id:
                        type: string
                        format: uuid
                        description: task ID
                      status:
                        type: string
                        enum:
                          - pending
                          - processing
                          - completed
                          - failed
                        description: task status
                      progress:
                        type: integer
                        minimum: 0
                        maximum: 100
                        description: task progress(0-100)
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '413':
          description: upload file too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '415':
          description: unsupported media type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  parameters:
    UuidParam:
      name: uuid
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: uuid
      example: 123e4567-e89b-12d3-a456-426614174000
  responses:
    ValidationError:
      description: validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: validation error
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: error message
    Unauthorized:
      description: unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: invalid api key or token
    NotFound:
      description: resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: not_found
              message:
                type: string
                example: resource not found
    StandardError:
      description: standard error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: error code
          example: invalid_request
        message:
          type: string
          description: error message
          example: invalid request
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: token
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: api key

````