Class: OpenAI::Resources::Videos

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Videos

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

Parameters:



268
269
270
# File 'lib/openai/resources/videos.rb', line 268

def initialize(client:)
  @client = client
end

Instance Method Details

#create(prompt:, input_reference: nil, model: nil, seconds: nil, size: nil, request_options: {}) ⇒ OpenAI::Models::Video

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

Create a new video generation job from a prompt and optional reference assets.

Parameters:

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openai/resources/videos.rb', line 28

def create(params)
  parsed, options = OpenAI::VideoCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "videos",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Video,
    options: options
  )
end

#create_character(name:, video:, request_options: {}) ⇒ OpenAI::Models::VideoCreateCharacterResponse

Create a character from an uploaded video.

Parameters:

  • name (String)

    Display name for this API character.

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

    Video file used to create a character.

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

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/openai/resources/videos.rb', line 124

def create_character(params)
  parsed, options = OpenAI::VideoCreateCharacterParams.dump_request(params)
  @client.request(
    method: :post,
    path: "videos/characters",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Models::VideoCreateCharacterResponse,
    options: options
  )
end

#delete(video_id, request_options: {}) ⇒ OpenAI::Models::VideoDeleteResponse

Permanently delete a completed or failed video and its stored assets.

Parameters:

  • video_id (String)

    The identifier of the video to delete.

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

Returns:

See Also:



102
103
104
105
106
107
108
109
# File 'lib/openai/resources/videos.rb', line 102

def delete(video_id, params = {})
  @client.request(
    method: :delete,
    path: ["videos/%1$s", video_id],
    model: OpenAI::Models::VideoDeleteResponse,
    options: params[:request_options]
  )
end

#download_content(video_id, variant: nil, request_options: {}) ⇒ StringIO

Download the generated video bytes or a derived preview asset.

Streams the rendered video content for the specified video job.

Parameters:

Returns:

  • (StringIO)

See Also:



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/openai/resources/videos.rb', line 151

def download_content(video_id, params = {})
  parsed, options = OpenAI::VideoDownloadContentParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["videos/%1$s/content", video_id],
    query: query,
    headers: {"accept" => "application/binary"},
    model: StringIO,
    options: options
  )
end

#edit(prompt:, video:, request_options: {}) ⇒ OpenAI::Models::Video

Create a new video generation job by editing a source video or existing generated video.

Parameters:

Returns:

See Also:



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/openai/resources/videos.rb', line 178

def edit(params)
  parsed, options = OpenAI::VideoEditParams.dump_request(params)
  @client.request(
    method: :post,
    path: "videos/edits",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Video,
    options: options
  )
end

#extend_(prompt:, seconds:, video:, request_options: {}) ⇒ OpenAI::Models::Video

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

Create an extension of a completed video.

Parameters:

Returns:

See Also:



208
209
210
211
212
213
214
215
216
217
218
# File 'lib/openai/resources/videos.rb', line 208

def extend_(params)
  parsed, options = OpenAI::VideoExtendParams.dump_request(params)
  @client.request(
    method: :post,
    path: "videos/extensions",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Video,
    options: options
  )
end

#get_character(character_id, request_options: {}) ⇒ OpenAI::Models::VideoGetCharacterResponse

Fetch a character.

Parameters:

  • character_id (String)

    The identifier of the character to retrieve.

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

Returns:

See Also:



231
232
233
234
235
236
237
238
# File 'lib/openai/resources/videos.rb', line 231

def get_character(character_id, params = {})
  @client.request(
    method: :get,
    path: ["videos/characters/%1$s", character_id],
    model: OpenAI::Models::VideoGetCharacterResponse,
    options: params[:request_options]
  )
end

#list(after: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::ConversationCursorPage<OpenAI::Models::Video>

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

List recently generated videos for the current project.

Parameters:

  • after (String)

    Identifier for the last item from the previous pagination request

  • limit (Integer)

    Number of items to retrieve

  • order (Symbol, OpenAI::Models::VideoListParams::Order)

    Sort order of results by timestamp. Use ‘asc` for ascending order or `desc` for

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

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/openai/resources/videos.rb', line 78

def list(params = {})
  parsed, options = OpenAI::VideoListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "videos",
    query: query,
    page: OpenAI::Internal::ConversationCursorPage,
    model: OpenAI::Video,
    options: options
  )
end

#remix(video_id, prompt:, request_options: {}) ⇒ OpenAI::Models::Video

Create a remix of a completed video using a refreshed prompt.

Parameters:

  • video_id (String)

    The identifier of the completed video to remix.

  • prompt (String)

    Updated text prompt that directs the remix generation.

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

Returns:

See Also:



253
254
255
256
257
258
259
260
261
262
263
# File 'lib/openai/resources/videos.rb', line 253

def remix(video_id, params)
  parsed, options = OpenAI::VideoRemixParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["videos/%1$s/remix", video_id],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Video,
    options: options
  )
end

#retrieve(video_id, request_options: {}) ⇒ OpenAI::Models::Video

Fetch the latest metadata for a generated video.

Parameters:

  • video_id (String)

    The identifier of the video to retrieve.

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

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/openai/resources/videos.rb', line 51

def retrieve(video_id, params = {})
  @client.request(
    method: :get,
    path: ["videos/%1$s", video_id],
    model: OpenAI::Video,
    options: params[:request_options]
  )
end