Class: Anthropic::Resources::Beta::Files
- Inherits:
-
Object
- Object
- Anthropic::Resources::Beta::Files
- Defined in:
- lib/anthropic/resources/beta/files.rb
Instance Method Summary collapse
-
#delete(file_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::DeletedFile
Delete File.
-
#download(file_id, betas: nil, request_options: {}) ⇒ StringIO
Download File.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(after_id: nil, before_id: nil, limit: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Beta::FileMetadata>
Some parameter documentations has been truncated, see Models::Beta::FileListParams for more details.
-
#retrieve_metadata(file_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::FileMetadata
Get File Metadata.
-
#upload(file: , betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::FileMetadata
Upload File.
Constructor Details
#initialize(client:) ⇒ Files
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Files.
147 148 149 |
# File 'lib/anthropic/resources/beta/files.rb', line 147 def initialize(client:) @client = client end |
Instance Method Details
#delete(file_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::DeletedFile
Delete File
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/anthropic/resources/beta/files.rb', line 54 def delete(file_id, params = {}) parsed, = Anthropic::Beta::FileDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v1/files/%1$s?beta=true", file_id], headers: parsed.transform_keys(betas: "anthropic-beta"), model: Anthropic::Beta::DeletedFile, options: {extra_headers: {"anthropic-beta" => "files-api-2025-04-14"}, **} ) end |
#download(file_id, betas: nil, request_options: {}) ⇒ StringIO
Download File
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/anthropic/resources/beta/files.rb', line 78 def download(file_id, params = {}) parsed, = Anthropic::Beta::FileDownloadParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s/content?beta=true", file_id], headers: {"accept" => "application/binary", **parsed}.transform_keys(betas: "anthropic-beta"), model: StringIO, options: {extra_headers: {"anthropic-beta" => "files-api-2025-04-14"}, **} ) end |
#list(after_id: nil, before_id: nil, limit: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Beta::FileMetadata>
Some parameter documentations has been truncated, see Models::Beta::FileListParams for more details.
List Files
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/anthropic/resources/beta/files.rb', line 27 def list(params = {}) parsed, = Anthropic::Beta::FileListParams.dump_request(params) query_params = [:after_id, :before_id, :limit] @client.request( method: :get, path: "v1/files?beta=true", query: parsed.slice(*query_params), headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"), page: Anthropic::Internal::Page, model: Anthropic::Beta::FileMetadata, options: {extra_headers: {"anthropic-beta" => "files-api-2025-04-14"}, **} ) end |
#retrieve_metadata(file_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::FileMetadata
Get File Metadata
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/anthropic/resources/beta/files.rb', line 102 def (file_id, params = {}) parsed, = Anthropic::Beta::FileRetrieveMetadataParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s?beta=true", file_id], headers: parsed.transform_keys(betas: "anthropic-beta"), model: Anthropic::Beta::FileMetadata, options: {extra_headers: {"anthropic-beta" => "files-api-2025-04-14"}, **} ) end |
#upload(file: , betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::FileMetadata
Upload File
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/anthropic/resources/beta/files.rb', line 126 def upload(params) parsed, = Anthropic::Beta::FileUploadParams.dump_request(params) header_params = {betas: "anthropic-beta"} @client.request( method: :post, path: "v1/files?beta=true", headers: { "content-type" => "multipart/form-data", **parsed.slice(*header_params.keys) }.transform_keys( header_params ), body: parsed.except(*header_params.keys), model: Anthropic::Beta::FileMetadata, options: {extra_headers: {"anthropic-beta" => "files-api-2025-04-14"}, **} ) end |