Class: OpenAI::Resources::Uploads::Parts

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/uploads/parts.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Parts

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 Parts.

Parameters:



48
49
50
# File 'lib/openai/resources/uploads/parts.rb', line 48

def initialize(client:)
  @client = client
end

Instance Method Details

#create(upload_id, data: , request_options: {}) ⇒ OpenAI::Models::Uploads::UploadPart

Some parameter documentations has been truncated, see Models::Uploads::PartCreateParams for more details.

Adds a [Part](platform.openai.com/docs/api-reference/uploads/part-object) to an [Upload](platform.openai.com/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload.

Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.

It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](platform.openai.com/docs/api-reference/uploads/complete).

Parameters:

  • upload_id (String)

    The ID of the Upload.

  • data (Pathname, StringIO, IO, String, OpenAI::FilePart)

    The chunk of bytes for this Part.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/openai/resources/uploads/parts.rb', line 33

def create(upload_id, params)
  parsed, options = OpenAI::Uploads::PartCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["uploads/%1$s/parts", upload_id],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Uploads::UploadPart,
    options: options
  )
end