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

# Get Agent File

> Get agent generated file by file ID

## 获取智能体生成的文件

**URL**: `/v1/agent/files/{file_id}`\
**方法**: `GET`\
**描述**: 获取智能体在对话过程中生成的文件，如报告、图表等。

### 路径参数

| 参数名      | 类型     | 必填 | 描述          |
| -------- | ------ | -- | ----------- |
| file\_id | string | 是  | 智能体生成的文件 ID |

### 响应

成功时返回文件的二进制内容（`application/octet-stream`）。

### 请求示例

**cURL**

```bash theme={null}
curl -X GET "https://api.reportify.cn/v1/agent/files/file_abc123" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o downloaded_file.pdf
```

**Python**

```python theme={null}
import requests

url = "https://api.reportify.cn/v1/agent/files/file_abc123"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.get(url, headers=headers)

# Save to file
with open("downloaded_file.pdf", "wb") as f:
    f.write(response.content)
```

**TypeScript**

```typescript theme={null}
const response = await fetch(
  'https://api.reportify.cn/v1/agent/files/file_abc123',
  {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  }
);

const blob = await response.blob();
// Save or process the blob
```

### 错误响应

| 状态码 | 描述       |
| --- | -------- |
| 404 | 文件不存在    |
| 422 | 请求参数验证失败 |

### 使用场景

1. **下载智能体生成的报告**
   * 智能体在分析过程中可能会生成 PDF 报告或 Excel 文件
   * 使用此接口下载这些生成的文件

2. **获取图表和可视化**
   * 智能体可能会生成数据可视化图表
   * 通过文件 ID 下载对应的图表文件

<Tip>
  文件 ID 通常在智能体的事件流中返回，在 `tool_output` 或 `workflow_end` 事件中包含生成的文件信息。
</Tip>


## OpenAPI

````yaml GET /v1/agent/files/{file_id}
openapi: 3.1.0
info:
  title: Reportify API
  version: 1.0.0
  description: API documentation for Reportify's document management and search services.
servers:
  - url: https://api.reportify.cn
    description: Production server
security:
  - BearerAuth: []
paths:
  /v1/agent/files/{file_id}:
    get:
      tags:
        - openapi-agent
      summary: Get Agent File
      description: Get agent generated file by file ID
      operationId: get_agent_file_reportify_api_v1_agent_files__file_id__get
      parameters:
        - required: true
          schema:
            type: string
            title: File Id
            description: Agent generated file ID
          name: file_id
          in: path
      responses:
        '200':
          description: Successful Response
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '404':
          description: File not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    ErrorResponse:
      properties:
        status:
          type: integer
          title: Status
          description: HTTP status code
        code:
          type: integer
          title: Code
          description: Error code
        message:
          type: string
          title: Message
          description: Error message
      type: object
      title: ErrorResponse
      description: Standard error response
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your Bearer token

````