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

# 获取文件

> 通过文件ID检索文件的元数据。

## 概述

使用此端点，你可以通过文件的唯一标识符（ID）检索文件的元数据。元数据包括文件的名称、大小、创建日期等信息。

## 请求

### HTTP 请求

`GET /v1/files/{file_id}`

### 路径参数

* `file_id` *(string)*: 需要检索的文件的唯一标识符。

## 响应

成功的响应将返回一个包含文件元数据的 JSON 对象。

### 响应示例

```json theme={null}
{
  "id": "file_123",
  "name": "example.txt",
  "size": 1024,
  "created_at": "2023-01-01T12:00:00Z"
}
```

## 错误

如果请求的文件不存在，API 将返回一个错误响应。

### 错误示例

```json theme={null}
{
  "error": {
    "code": "file_not_found",
    "message": "The requested file does not exist."
  }
}
```

## 相关端点

* [上传文件](/api-reference/files/upload)
* [删除文件](/api-reference/files/delete)

## 备注

确保在请求中提供有效的 `file_id`，否则将无法检索到文件的元数据。


## OpenAPI

````yaml zh/openapi/files.json GET /v1/files/{file_id}
openapi: 3.0.3
info:
  title: 文件 API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/files/{file_id}:
    get:
      summary: 通过ID获取文件元数据
      description: 通过文件ID检索元数据。
      parameters:
        - name: file_id
          in: path
          required: true
          description: 要检索的文件的唯一标识符。
          schema:
            type: string
      responses:
        '200':
          description: 成功响应文件元数据。
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 文件 ID
                  object:
                    type: string
                    description: 对象类型。此端点为 "file"。
                  created:
                    type: integer
                    description: 创建的纪元时间戳
                  filename:
                    type: string
                    description: 上传文件的文件名
                  bytes:
                    type: integer
                    description: 文件大小（字节）
                  purpose:
                    type: string
                    description: 文件的用途
                  status:
                    type: string
                    description: 文件状态（例如，"pending"，"completed"）
        '401':
          description: 无效的 API 密钥
        '404':
          description: 文件未找到
        '500':
          description: 内部服务器错误
      security:
        - Authorization: []
components:
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer认证头格式为Bearer <token>，其中<token>是你的认证令牌。

````