All URIs are relative to https://api.openai.com/v1
Method | HTTP request | Description |
---|---|---|
create_file | POST /files | Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files for can be a maximum of 512MB. See the Assistants Tools guide to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files. Please contact us if you need to increase these storage limits. |
delete_file | DELETE /files/{file_id} | Delete a file. |
download_file | GET /files/{file_id}/content | Returns the contents of the specified file. |
list_files | GET /files | Returns a list of files that belong to the user's organization. |
retrieve_file | GET /files/{file_id} | Returns information about a specific file. |
create_file(file, purpose)
Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files for can be a maximum of 512MB. See the Assistants Tools guide to learn more about the types of files supported. The Fine-tuning API only supports .jsonl
files. Please contact us if you need to increase these storage limits.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::FilesApi.new
file = File.new('/path/to/some/file') # File | The File object (not file name) to be uploaded.
purpose = 'fine-tune' # String | The intended purpose of the uploaded file. Use \\\"fine-tune\\\" for [Fine-tuning](/docs/api-reference/fine-tuning) and \\\"assistants\\\" for [Assistants](/docs/api-reference/assistants) and [Messages](/docs/api-reference/messages). This allows us to validate the format of the uploaded file is correct for fine-tuning.
begin
# Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files for can be a maximum of 512MB. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files. Please [contact us](https://help.openai.com/) if you need to increase these storage limits.
result = api_instance.create_file(file, purpose)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->create_file: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_file_with_http_info(file, purpose)
begin
# Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files for can be a maximum of 512MB. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files. Please [contact us](https://help.openai.com/) if you need to increase these storage limits.
data, status_code, headers = api_instance.create_file_with_http_info(file, purpose)
p status_code # => 2xx
p headers # => { ... }
p data # => <OpenAIFile>
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->create_file_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
file | File | The File object (not file name) to be uploaded. | |
purpose | String | The intended purpose of the uploaded file. Use \"fine-tune\" for Fine-tuning and \"assistants\" for Assistants and Messages. This allows us to validate the format of the uploaded file is correct for fine-tuning. |
- Content-Type: multipart/form-data
- Accept: application/json
delete_file(file_id)
Delete a file.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::FilesApi.new
file_id = 'file_id_example' # String | The ID of the file to use for this request.
begin
# Delete a file.
result = api_instance.delete_file(file_id)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->delete_file: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> delete_file_with_http_info(file_id)
begin
# Delete a file.
data, status_code, headers = api_instance.delete_file_with_http_info(file_id)
p status_code # => 2xx
p headers # => { ... }
p data # => <DeleteFileResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->delete_file_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
file_id | String | The ID of the file to use for this request. |
- Content-Type: Not defined
- Accept: application/json
String download_file(file_id)
Returns the contents of the specified file.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::FilesApi.new
file_id = 'file_id_example' # String | The ID of the file to use for this request.
begin
# Returns the contents of the specified file.
result = api_instance.download_file(file_id)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->download_file: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(String, Integer, Hash)> download_file_with_http_info(file_id)
begin
# Returns the contents of the specified file.
data, status_code, headers = api_instance.download_file_with_http_info(file_id)
p status_code # => 2xx
p headers # => { ... }
p data # => String
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->download_file_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
file_id | String | The ID of the file to use for this request. |
String
- Content-Type: Not defined
- Accept: application/json
list_files(opts)
Returns a list of files that belong to the user's organization.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::FilesApi.new
opts = {
purpose: 'purpose_example' # String | Only return files with the given purpose.
}
begin
# Returns a list of files that belong to the user's organization.
result = api_instance.list_files(opts)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->list_files: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> list_files_with_http_info(opts)
begin
# Returns a list of files that belong to the user's organization.
data, status_code, headers = api_instance.list_files_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <ListFilesResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->list_files_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
purpose | String | Only return files with the given purpose. | [optional] |
- Content-Type: Not defined
- Accept: application/json
retrieve_file(file_id)
Returns information about a specific file.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::FilesApi.new
file_id = 'file_id_example' # String | The ID of the file to use for this request.
begin
# Returns information about a specific file.
result = api_instance.retrieve_file(file_id)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->retrieve_file: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> retrieve_file_with_http_info(file_id)
begin
# Returns information about a specific file.
data, status_code, headers = api_instance.retrieve_file_with_http_info(file_id)
p status_code # => 2xx
p headers # => { ... }
p data # => <OpenAIFile>
rescue OpenapiClient::ApiError => e
puts "Error when calling FilesApi->retrieve_file_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
file_id | String | The ID of the file to use for this request. |
- Content-Type: Not defined
- Accept: application/json