runapi-gpt-image-2 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93e24a0cc8419599b2adea4066cf690d2181f89e2b2644834373e971d542f38d
4
- data.tar.gz: 7389dcf5a964ca44a6ecc6a377d1b989711503df69a267815ca41a0388691ae3
3
+ metadata.gz: 7664913b3073c7ef5cec93d7661a89f41df732140b1bb741f558b37a0c707484
4
+ data.tar.gz: ed6c4be520bcaaab01bf5a20be19cff0947ca1951c961fb8eae93a9713a62007
5
5
  SHA512:
6
- metadata.gz: 8e0439329c6d4f35c72539f1f6fae4ed3a8948e0a848f2a3ca14451632f9e50a119491251c4c3c21fe1ff77cba5c087374ee56ac3d6cbb4301abc94228025516
7
- data.tar.gz: 197a2fb299f84efa8a5a004765913658cc7112dade20daa15f1b1e4a53a6c712d3bb102dcc1d4903326d5bf707a9168f7c4631687869dc43f53d0017eaa6e990
6
+ metadata.gz: deeb9ac2db537db1101e79fe045c5906aac1b4e573f13dedf01dd562001e8047869612e2f5a0fcd5f80aafe9eae81a0ffe8580ce71930011d722439b06495b5b
7
+ data.tar.gz: 223abf29ac0d43b6c71113101e69b050c8618471c934c5c0a0d900c7718f3fe3612e5888213ddc1ae8530bab3528b1ac19c5949da121069c27cfe64015efa027
data/README.md CHANGED
@@ -24,6 +24,8 @@ status = client.generations.get(task.id)
24
24
 
25
25
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
26
26
 
27
+ RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
28
+
27
29
  ## Language notes
28
30
 
29
31
  Use Ruby keyword arguments and the `RunApi::GptImage2` error classes when building image jobs, Rails workers, or scripts. The available resources include generations, and edits. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
@@ -2,14 +2,31 @@
2
2
 
3
3
  module RunApi
4
4
  module GptImage2
5
- class Client
6
- attr_reader :text_to_image, :edit_image
5
+ # GPT Image 2 generation and editing API client.
6
+ #
7
+ # Supports up to 4k output resolution and 'auto' aspect ratio.
8
+ #
9
+ # @example
10
+ # client = RunApi::GptImage2::Client.new(api_key: "your-api-key")
11
+ #
12
+ # # Text-to-image
13
+ # result = client.text_to_image.run(
14
+ # model: "gpt-image-2", prompt: "A futuristic cityscape"
15
+ # )
16
+ #
17
+ # # Edit image
18
+ # edited = client.edit_image.run(
19
+ # model: "gpt-image-2", prompt: "Transform into oil painting",
20
+ # source_image_urls: ["https://example.com/photo.jpg"]
21
+ # )
22
+ class Client < RunApi::Core::Client
23
+ # @return [Resources::TextToImage] Text-to-image generation operations.
24
+ attr_reader :text_to_image
25
+ # @return [Resources::EditImage] Prompt-guided image editing operations.
26
+ attr_reader :edit_image
7
27
 
8
28
  def initialize(api_key: nil, **options)
9
- @api_key = Core::Auth.resolve_api_key(api_key)
10
-
11
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
12
- http = client_options.http_client || Core::HttpClient.new(client_options)
29
+ super
13
30
  @text_to_image = Resources::TextToImage.new(http)
14
31
  @edit_image = Resources::EditImage.new(http)
15
32
  end
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module GptImage2
5
5
  module Resources
6
+ # GPT Image 2 prompt-guided image editing resource.
7
+ # Apply text-guided edits to source images (up to 16).
6
8
  class EditImage
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module GptImage2
5
5
  module Resources
6
+ # GPT Image 2 text-to-image generation resource.
7
+ # Generate images from text with up to 4k output resolution.
6
8
  class TextToImage
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -2,18 +2,24 @@
2
2
 
3
3
  module RunApi
4
4
  module GptImage2
5
+ # Type definitions and constants for GPT Image 2.
6
+ # Unlike GPT Image 1.5, aspect_ratio and output_resolution are optional.
5
7
  module Types
6
8
  MODELS = %w[gpt-image-2].freeze
7
9
  GENERATION_MODELS = MODELS
8
10
  EDIT_MODELS = MODELS
9
11
 
12
+ # 'auto' lets the model choose based on the prompt content.
10
13
  ASPECT_RATIOS = %w[auto 1:1 9:16 16:9 4:3 3:4].freeze
14
+ # Output resolution tiers. 1:1 is limited to 1k and 2k.
11
15
  RESOLUTIONS = %w[1k 2k 4k].freeze
12
16
 
17
+ # A single generated image with its CDN URL.
13
18
  class Image < RunApi::Core::BaseModel
14
19
  optional :url, String
15
20
  end
16
21
 
22
+ # Generation result. +images+ is populated once +status+ is +"completed"+.
17
23
  class TextToImageResponse < RunApi::Core::TaskResponse
18
24
  required :id, String
19
25
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -21,8 +27,10 @@ module RunApi
21
27
  optional :error, String
22
28
  end
23
29
 
30
+ # Edit response -- same shape as generation.
24
31
  EditImageResponse = TextToImageResponse
25
32
 
33
+ # Narrowed response from +run()+ where +images+ is guaranteed present.
26
34
  class CompletedTextToImageResponse < TextToImageResponse
27
35
  required :images, [-> { Image }]
28
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-gpt-image-2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.5
18
+ version: 0.2.6
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.5
25
+ version: 0.2.6
26
26
  description: The gpt image 2 api Ruby SDK is the language-specific package for GPT
27
27
  Image 2 on RunAPI. Use this gpt image 2 api package for text-to-image, image editing,
28
28
  and creative production flows when your application needs JSON request bodies, task