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

# 创建文件上传

> 生成用于上传 JSON 文件的预签名 URL。上传后，你必须调用 [complete endpoint](/api-reference/files/complete) 来完成上传。



## OpenAPI

````yaml zh/openapi/files.json POST /v1/files
openapi: 3.0.3
info:
  title: 文件 API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/files:
    post:
      summary: 创建文件上传
      description: 生成一个用于上传 JSON 文件的预签名 URL。上传后，你必须调用 complete 端点来完成上传。上传 URL 在 10 分钟后过期。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  description: 文件的文件名。必须以 .json 扩展名结尾。
                  pattern: \.json$
                purpose:
                  type: string
                  description: 文件的用途。支持的值：'context' 或 'batch'。默认为 'context'。
                  enum:
                    - context
                    - batch
                  default: context
              required:
                - filename
      responses:
        '200':
          description: 成功响应，包含上传 URL。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 文件 ID
                  object:
                    type: string
                    description: 对象类型。此端点为 "file.upload"。
                  created:
                    type: integer
                    description: 创建的纪元时间戳
                  upload_url:
                    type: string
                    format: uri
                    description: 用于上传文件的预签名 URL。10 分钟后过期。
                  expires_in:
                    type: integer
                    description: 上传 URL 过期的秒数（600 秒 = 10 分钟）
        '400':
          description: 错误请求。缺少文件名或文件类型无效（仅支持 .json 文件）。
        '401':
          description: 无效的 API 密钥
        '500':
          description: 内部服务器错误
      security:
        - Authorization: []
components:
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer认证头格式为Bearer <token>，其中<token>是你的认证令牌。

````