Class: WhopSDK::Resources::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/media.rb,
sig/whop_sdk/resources/media.rbs

Overview

A Media Asset is an AI-generated image or video created from a prompt and billed from an account balance. When generation finishes, the asset includes a file that can be attached anywhere Whop accepts files.

Use the Media API to start a generation job and retrieve the asset while it processes or after it is ready.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Media

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

Parameters:



72
73
74
# File 'lib/whop_sdk/resources/media.rb', line 72

def initialize(client:)
  @client = client
end

Instance Method Details

#generate(prompt:, type:, account_id: nil, duration_seconds: nil, reference_media: nil, resolution: nil, request_options: {}) ⇒ WhopSDK::Models::MediaAsset

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

Starts an AI media generation job billed from the account's balance. Generation is asynchronous — poll GET /media/{id} until the asset is ready, then use file.id anywhere attachments are accepted.

Parameters:

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
# File 'lib/whop_sdk/resources/media.rb', line 58

def generate(params)
  parsed, options = WhopSDK::MediaGenerateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "media/generate",
    body: parsed,
    model: WhopSDK::MediaAsset,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::MediaAsset

Retrieves a media asset by ID. Poll this while the asset is processing.

Parameters:

  • id (String)

    Media asset ID, prefixed media_.

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

Returns:

See Also:



23
24
25
26
27
28
29
30
# File 'lib/whop_sdk/resources/media.rb', line 23

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["media/%1$s", id],
    model: WhopSDK::MediaAsset,
    options: params[:request_options]
  )
end