# 查询文件状态

> 通用

根据文件 ID 查询文件详情与状态。
文件 `status` 为 `processed` 时，表示可用于创建 batch 任务。
该接口也可用于下载结果时查询 `output_file_id` / `error_file_id` 对应文件的信息。

## 请求地址

`GET https://api.modelverse.cn/v1/files/{file_id}`

## 请求参数

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| file_id | path | string | Yes | 文件 ID，即上传接口返回的 `id`。 |

## 响应

- **200** — 文件详情。
- **404** — 文件不存在或无权限访问。
- **default** — 错误响应。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "批量任务-查询文件状态接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 **OpenAI 兼容批量（Batch）异步任务**的第 2 步：查询文件状态。\n上传输入文件后，可查询文件状态，确认 `status=processed` 后再创建 batch 任务。\n接口路径为 `GET /v1/files/{file_id}`。\n\n> **注意**：查询文件状态接口目前仅支持 GPT 系列模型（如 `gpt-5-batch`），其他模型的批量任务不支持通过该接口查询文件状态。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint."
    }
  ],
  "tags": [
    {
      "name": "批量异步任务",
      "description": "OpenAI 兼容的批量异步任务接口。"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/files/{file_id}": {
      "get": {
        "tags": [
          "批量异步任务"
        ],
        "operationId": "retrieveBatchFile",
        "summary": "查询文件状态",
        "description": "根据文件 ID 查询文件详情与状态。\n文件 `status` 为 `processed` 时，表示可用于创建 batch 任务。\n该接口也可用于下载结果时查询 `output_file_id` / `error_file_id` 对应文件的信息。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "description": "文件 ID，即上传接口返回的 `id`。",
            "schema": {
              "type": "string"
            },
            "example": "file-abc123"
          }
        ],
        "responses": {
          "200": {
            "description": "文件详情。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchFileObject"
                },
                "examples": {
                  "success": {
                    "summary": "文件已处理",
                    "value": {
                      "id": "file-abc123",
                      "object": "file",
                      "bytes": 512,
                      "created_at": 1781600000,
                      "filename": "batch_input.jsonl",
                      "purpose": "batch",
                      "status": "processed"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "文件不存在或无权限访问。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/BatchError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "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": "通过 HTTP 头 `Authorization` 携带 API Key，格式为 `Bearer <your_api_key>`。\n"
      }
    },
    "schemas": {
      "BatchFileObject": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "object",
          "bytes",
          "created_at",
          "filename",
          "purpose"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "文件 ID。"
          },
          "object": {
            "type": "string",
            "const": "file",
            "description": "对象类型，固定为 `file`。"
          },
          "bytes": {
            "type": "integer",
            "format": "int64",
            "description": "文件大小（字节）。"
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "创建时间戳（秒）。"
          },
          "expires_at": {
            "type": "integer",
            "format": "int64",
            "description": "过期时间戳（秒）。"
          },
          "filename": {
            "type": "string",
            "description": "文件名。"
          },
          "purpose": {
            "type": "string",
            "description": "文件用途，`batch` 表示批量任务输入文件。"
          },
          "status": {
            "type": "string",
            "description": "文件状态，`processed` 表示已处理完成、可用。",
            "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": "错误说明。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": "string",
            "description": "机器可读的错误码。"
          },
          "param": {
            "type": "string",
            "description": "出错的参数名或请求 ID。"
          }
        }
      }
    },
    "examples": {
      "BatchError": {
        "summary": "标准 JSON 错误响应",
        "value": {
          "error": {
            "message": "file not found",
            "type": "invalid_request_error",
            "code": "not_found",
            "param": "file_id"
          }
        }
      }
    }
  }
}
```
