Files API
You can use the Files API to securely upload and manage documents and other data that agents can use while they run.
By attaching files to workflows such as retrieval and summarizing tasks, agents can work with large or complex source materials without you having to paste content into prompts. This helps you build more capable agents that can use knowledge bases, reports, logs, and datasets in a scalable, reusable way—while keeping data handling centralized and consistent.
This service is not intended to process personal information or any data (for example, certain regulated health or payment card information) that imposes specific data security, data protection or regulatory obligations on Oracle in addition to or different from those specified in your agreement with Oracle.
The Files API uses the same format as the OpenAI Files API. See OpenAI Files API documentation.
Uploading a File
POST/files
- Body Parameters
-
file(required): file object to be uploadedpurpose(required): The intended purpose of the file. Supported values:assistantsbatchfine-tunevisionuser_dataevals
expires_after(optional): Expiration policy for the file
- File type restrictions (by purpose)
-
batch:.jsonlfine-tune:.jsonlevals:.jsonlvision:.gif,.jpeg,.jpg,.png,.webp
Example:
# upload files
file_path = "./demo_file.pdf"
with open(file_path, "rb") as f:
file = client.files.create(
file=f,
purpose="user_data"
)
print(file)
Listing Files
GET/files
- Input Parameters
-
after(optional): Cursor for use in paginationlimit(optional): Number of objects to be returnedorder(optional): Sort order bycreated_at("asc" or "desc")purpose(optional): Filter files by purpose
Example:
# list files
files_list = client.files.list(order="asc")
print(files_list)
Retrieving File Information
GET/files/{file_id}
- Input Parameter
-
file_id(required): Id of the file to be retrieved
Example:
# retrieve file
file = client.files.retrieve(file_id="file-fra-d5dd80c5-da8c-435e-b336-48ce9b346200")
print(file)
Retrieving File Content
GET/files/{file_id}/content
- Input Parameter
-
file_id(required): Id of the file whose content you want to retrieve
Example:
# retrieve file content
file = client.files.content(file_id="file-fra-d5dd80c5-da8c-435e-b336-48ce9b346200")
print(file.content)
Deleting a File
DELETE/files/{file_id}
- Input Parameter
-
file_id(required): Id of the file to be deleted
Example:
# delete file
delete_result = client.files.delete(file_id="file-xxx")
print(delete_result)