# Upload batch input file

> Common

Upload the batch input file (JSONL). `purpose` is fixed to `batch`.
Each line is an independent request with `custom_id`, `method`, `url`,
and `body`, where `body.model` determines the routed model and provider.

## Endpoint

`POST https://api.modelverse.cn/v1/files`

## Request Body

## Responses

- **200** — Upload succeeded; returns the file object.
- **400** — Invalid parameters or malformed input file.
- **default** — Error response.

## OpenAPI Definition

```json
{
  "openapi": "3.1.0",
  "x-language": "en-US",
  "info": {
    "title": "Batch Tasks - Upload Input File",
    "version": "1.0.0",
    "description": "Step 1 of the ModelVerse **OpenAI-compatible Batch async task** flow:\nupload the input file. Upload the batch input file (JSONL) to the platform\nand obtain a `file_id` for creating the batch task later.\nEndpoint: `POST /v1/files`.\n\nNote: the service automatically detects `body.model` from the first line of\nthe JSONL input file and routes the file and subsequent batch task to a\nprovider that can serve that model.\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint."
    }
  ],
  "tags": [
    {
      "name": "Batch Async Tasks",
      "description": "OpenAI-compatible batch async task APIs."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/files": {
      "post": {
        "tags": [
          "Batch Async Tasks"
        ],
        "operationId": "uploadBatchInputFile",
        "summary": "Upload batch input file",
        "description": "Upload the batch input file (JSONL). `purpose` is fixed to `batch`.\nEach line is an independent request with `custom_id`, `method`, `url`,\nand `body`, where `body.model` determines the routed model and provider.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadBatchFileRequest"
              },
              "encoding": {
                "file": {
                  "contentType": "application/octet-stream"
                }
              },
              "examples": {
                "default": {
                  "summary": "Upload a JSONL batch input file",
                  "value": {
                    "purpose": "batch",
                    "file": "/path/to/batch_input.jsonl"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload succeeded; returns the file object.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchFileObject"
                },
                "examples": {
                  "success": {
                    "summary": "Upload succeeded",
                    "value": {
                      "id": "file-abc123",
                      "object": "file",
                      "bytes": 512,
                      "created_at": 1781600000,
                      "expires_at": 0,
                      "filename": "batch_input.jsonl",
                      "purpose": "batch",
                      "status": "processed"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters or malformed input file.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/BatchError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/BatchError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Provide the API key via the `Authorization` header as\n`Bearer <your_api_key>`.\n"
      }
    },
    "schemas": {
      "UploadBatchFileRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "purpose",
          "file"
        ],
        "properties": {
          "purpose": {
            "type": "string",
            "const": "batch",
            "description": "File purpose. Fixed to `batch` for batch tasks."
          },
          "file": {
            "type": "string",
            "format": "binary",
            "description": "The batch input file (JSONL). Each line is an independent request\nobject: `custom_id` (custom unique id), `method` (fixed to `POST`),\n`url` (e.g. `/v1/chat/completions`), and `body` (the request body,\nincluding `model`).\n"
          }
        }
      },
      "BatchFileObject": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "object",
          "bytes",
          "created_at",
          "filename",
          "purpose"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "File ID, used to query file status, create a batch task, and download results."
          },
          "object": {
            "type": "string",
            "const": "file",
            "description": "Object type. Always `file`."
          },
          "bytes": {
            "type": "integer",
            "format": "int64",
            "description": "File size in bytes."
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "Creation timestamp (seconds)."
          },
          "expires_at": {
            "type": "integer",
            "format": "int64",
            "description": "Expiration timestamp (seconds); `0` means no expiration."
          },
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "purpose": {
            "type": "string",
            "description": "File purpose; `batch` here."
          },
          "status": {
            "type": "string",
            "description": "File status; `processed` means ready to create a task.",
            "examples": [
              "processed"
            ]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "message",
          "type"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message."
          },
          "type": {
            "type": "string",
            "description": "Error type.",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": "string",
            "description": "Machine-readable error code."
          },
          "param": {
            "type": "string",
            "description": "The offending parameter name or request ID."
          }
        }
      }
    },
    "examples": {
      "BatchError": {
        "summary": "Standard JSON error response",
        "value": {
          "error": {
            "message": "error description",
            "type": "invalid_request_error",
            "code": "error_code",
            "param": "purpose"
          }
        }
      }
    }
  }
}
```
