SpyBara
Go Premium

python/resources/files/methods/content/index.md 2026-06-09 06:34 UTC to 2026-06-10 15:48 UTC

This page contains 41 additions and 0 deletions.

2026
Wed 10 15:48

Retrieve file content

files.content(strfile_id) -> BinaryResponseContent

get /files/{file_id}/content

Returns the contents of the specified file.

Parameters

  • file_id: str

Returns

  • BinaryResponseContent

Example

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
response = client.files.content(
    "file_id",
)
print(response)
content = response.read()
print(content)

Example

from openai import OpenAI
client = OpenAI()

content = client.files.content("file-abc123")