> ## 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.

# Upload File

GeekAI provides file upload and content extraction capabilities, supporting various file formats, including images, audio, video, and documents (PDF/Office/plain text). You can upload files to be recognized through the file upload interface, and then obtain the file content through the file content extraction interface. With this basic service, you can implement higher-level business scenarios such as AI file conversation/RAG.

### cURL Request Example

```bash theme={null}
curl --location --request POST 'https://geekai.dev/api/v1/files' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--form 'file=@"/E:/Documents/geekai/test.pdf"'
```


## OpenAPI

````yaml openapi.yaml POST /files
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /files:
    post:
      tags:
        - Files
      summary: 文件上传接口
      description: 上传并处理各种格式的文件，支持获取文件URL、内容提取等功能。
      operationId: uploadFile
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    上传的文件，目前支持PDF/DOCX/XLSX/PPTX/PNG/JPG/JPEG/CSV/TXT/MD/MP3/MP4等格式
                  example: '@/E:/文档/test.pdf'
                purpose:
                  type: string
                  description: 上传目的,目前仅支持获取文件URL、文件内容提取
                  default: file-url
                  enum:
                    - file-url
                    - file-extract
                format:
                  type: string
                  description: 返回文件内容格式，目前仅支持文本格式
                  default: text
                  example: text
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                required:
                  - uuid
                  - status
                properties:
                  uuid:
                    type: string
                    format: uuid
                    description: 文件唯一ID,可通过该ID获取文件内容
                  name:
                    type: string
                    description: 文件名称
                  size:
                    type: integer
                    description: 文件大小
                  type:
                    type: string
                    description: 文件MIME类型
                  status:
                    type: string
                    description: '文件状态: pending（待处理）/reading（读取中）/failed（读取失败）/done（已读取）'
                    enum:
                      - pending
                      - reading
                      - processing
                      - failed
                      - done
                  md5:
                    type: string
                    description: 文件MD5值
                  url:
                    type: string
                    description: 文件URL地址
                  content:
                    type: string
                    description: 文件内容（只有status=done时，才会填充该字段）
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: invalid_file
                      message: 不支持的文件格式
        '401':
          $ref: '#/components/responses/Unauthorized'
        '413':
          description: 文件大小超出限制
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: file_too_large
                      message: 文件大小超过50MB限制
        '415':
          description: 不支持的文件类型
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: unsupported_media_type
                      message: 不支持的文件类型
        '500':
          $ref: '#/components/responses/StandardError'
components:
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  responses:
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````