文档

API 参考

上传文件

开始上传,使智能体可以在任务中使用该文件。

上传直接写入云存储。API 返回上传目标,从不接收字节。响应的 upload_type 选择流程,并依据你声明的 size_bytes 决定。

upload_type: "single"

  1. POST /experimental/files 返回 file_id、upload_url,以及随字节一起发送的 fields。
  2. 把字节以 multipart form-data POST 到 upload_url,并把 fields 中的每个键都作为表单字段。成功返回 204 No Content。
  3. 用空请求体调用 POST /experimental/files/{file_id}/finalize。

upload_type: "multipart"

  1. POST /experimental/files 返回 file_id、upload_id、part_size_bytes 与 part_count。
  2. 把文件拆成 part_count 个大小为 part_size_bytes 的分片,最后一片是余数。
  3. 用 upload_id 与想要的分片编号调用 POST /experimental/files/{file_id}/parts,它会为每个分片返回 PUT URL。你可以分批请求。
  4. 把每个分片 PUT 到它的 URL,并保留该分片编号对应的 ETag 响应头。
  5. 调用 POST /experimental/files/{file_id}/finalize,请求体为 { "upload_id": "…", "parts": [{ "part_number": 1, "etag": "…" }, … ] }。

完成后,在 POST /experimental/tasks/{id}/messages 中用 file_ids 把 file_id 附加到任务。

OpenAPI

openapi: 3.1.0
info:
  title: BioAgent API — V1
  description: Public API for BioAgent, the biomedical AI agent platform.
  version: 0.1.0
servers:
  - url: https://bioagent.cloud/api/v1
    description: >-
      BioAgent public API base URL. Every endpoint on this page is served from
      this host.
security: []
paths:
  /experimental/files:
    post:
      tags:
        - files
      summary: Upload a file
      description: Start an upload so the agent can use the file in a task.
      operationId: request_upload_experimental_files_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFileRequest'
            examples:
              minimal:
                summary: Minimal — VCF input file
                value:
                  project_id: prj_0126xxQZB9MmSUaTs1MtRAgU
                  filename: patient001_brca1.vcf
                  size_bytes: 4321
              with_mime:
                summary: With mime_type
                value:
                  project_id: prj_0126xxQZB9MmSUaTs1MtRAgU
                  filename: Patient001_BRCA1_variant_report.json
                  size_bytes: 13913
                  mime_type: application/json
      responses:
        '200':
          description: >-
            Upload started. For `upload_type=single`, POST the bytes to
            `upload_url` with `fields`. For `upload_type=multipart`, pass
            `upload_id` to `POST /experimental/files/{file_id}/parts`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadIntent'
              examples:
                single:
                  summary: Small file — single POST
                  value:
                    type: upload_intent
                    file_id: file_017jG6PPIYy41dqnVz47lrmo
                    project_id: prj_014OwAG97UY0UfcHlLHQRnKO
                    path: >-
                      orgs/<org>/users/<user>/uploads/projects/proj_6b3606df1c/patient001_brca1.vcf
                    upload_type: single
                    expires_at: '2026-08-12T22:20:08.147475Z'
                    filename: patient001_brca1.vcf
                    size_bytes: 4321
                    mime_type: text/plain
                    upload_url: https://<bucket>.s3.us-west-2.amazonaws.com/
                    fields:
                      Content-Type: text/plain
                      key: >-
                        orgs/<org>/users/<user>/uploads/projects/proj_6b3606df1c/patient001_brca1.vcf
                      x-amz-algorithm: AWS4-HMAC-SHA256
                      x-amz-credential: <credential>/20260812/us-west-2/s3/aws4_request
                      x-amz-date: 20260812T220508Z
                      x-amz-security-token: <token>
                      policy: eyJleHBpcmF0aW9uIjoiMjAyNi0w...
                      x-amz-signature: 5a8d...
                multipart:
                  summary: Large file — multipart upload
                  value:
                    type: upload_intent
                    file_id: file_010kaWC7SjxErybg3OdscqX8
                    project_id: prj_014OwAG97UY0UfcHlLHQRnKO
                    path: >-
                      orgs/<org>/users/<user>/uploads/projects/proj_6b3606df1c/wgs_sample.cram
                    upload_type: multipart
                    expires_at: '2026-08-13T22:06:07.384079Z'
                    filename: wgs_sample.cram
                    size_bytes: 21474836480
                    mime_type: application/octet-stream
                    upload_id: aUU9ZO9qqsHiXssnDqXzfUlAMHYzK537OiMUJrsJrfsCoHXFm...
                    part_size_bytes: 33554432
                    part_count: 640
      security:
        - bearerAuth: []
components:
  schemas:
    CreateFileRequest:
      properties:
        project_id:
          type: string
          title: Project Id
        filename:
          type: string
          title: Filename
        size_bytes:
          type: integer
          title: Size Bytes
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
      additionalProperties: false
      type: object
      required:
        - project_id
        - filename
        - size_bytes
      title: CreateFileRequest
    UploadIntent:
      properties:
        type:
          type: string
          const: upload_intent
          title: Type
          default: upload_intent
        file_id:
          anyOf:
            - type: string
            - type: 'null'
          title: File Id
        project_id:
          type: string
          title: Project Id
        path:
          anyOf:
            - type: string
            - type: 'null'
          title: Path
        upload_type:
          type: string
          enum:
            - single
            - multipart
          title: Upload Type
          default: single
        upload_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Upload Url
        fields:
          additionalProperties: true
          type: object
          title: Fields
        upload_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Upload Id
        part_size_bytes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Part Size Bytes
        part_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Part Count
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        filename:
          type: string
          title: Filename
        size_bytes:
          type: integer
          title: Size Bytes
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
      type: object
      required:
        - project_id
        - filename
        - size_bytes
      title: UploadIntent
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Requires an API key. See the Authentication guide.