runapi-gpt-image 0.2.4 → 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: d7077b69df98c9dabd0c94760877f1406f9359cc8aeaccbeecf82cb07faa677c
4
- data.tar.gz: 4ed9190bc5ee799a3be8194ff191c7d4331b17f0282e62dada30750436ce9135
3
+ metadata.gz: cd933bb97d1ca6a8ccf0708928f4985b1cfb06aae5cef4ec9d65b8b84448d0b1
4
+ data.tar.gz: cd13517224d400ec1f493166b6fc9ce4b6c479c967e14b680efa4f0c4f1db2f2
5
5
  SHA512:
6
- metadata.gz: 8b07b7ca66c3c7307c9544cbc5493e67a1c241562f531aca037f5cd7a38cc7440827729d4c918d18a0b34bdf252a585d3aa73f174899994b3251a6e7ec4f6eb5
7
- data.tar.gz: c6d80eaf49c615d4172e8b277eb1c68bbd694f1898ef816bdc28e40e5c6fcd1d5bfacaf01c04d363e8a512baf94fdfdaafc848242ca90b9eabdc0dc1c83ca40c
6
+ metadata.gz: 2706384365717c217ffd71e4e654e92c1e24bb57318cd07cf7a420f78f1cb33a74faf19c0e01d6b30075e4d180204afc21cf66a5f6ce6f5a6f975d5eda50d3e6
7
+ data.tar.gz: 2c3b05a82ff0868976e4c0c0277dd1b8baeb9364eb816da8989f7161a6b91a9a36aa9a882e78a8de055a8ed1812e62146098dfb74e5d75285896e41f3fe65b18
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # GPT Image API Ruby SDK for RunAPI
2
+
3
+ The gpt image api Ruby SDK is the language-specific package for GPT Image on RunAPI. Use this gpt image api package for text-to-image, image editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
+
5
+ This gpt image api README is the Ruby package guide inside the public `gpt-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/gpt-image; for API reference, use https://runapi.ai/docs#gpt-image; for SDK docs, use https://runapi.ai/docs#sdk-gpt-image.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-gpt-image
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-gpt-image"
17
+
18
+ client = RunApi::GptImage::Client.new
19
+ task = client.generations.create(
20
+ # Pass the GPT Image JSON request body from https://runapi.ai/docs#gpt-image.
21
+ )
22
+ status = client.generations.get(task.id)
23
+ ```
24
+
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
+
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
+
29
+ ## Language notes
30
+
31
+ Use Ruby keyword arguments and the `RunApi::GptImage` 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.
32
+
33
+ ## Links
34
+
35
+ - Model page: https://runapi.ai/models/gpt-image
36
+ - SDK docs: https://runapi.ai/docs#sdk-gpt-image
37
+ - Product docs: https://runapi.ai/docs#gpt-image
38
+ - Pricing and rate limits: https://runapi.ai/models/gpt-image
39
+ - Provider comparison: https://runapi.ai/providers/openai
40
+ - Full catalog: https://runapi.ai/models
41
+ - Repository: https://github.com/runapi-ai/gpt-image-sdk
42
+
43
+ ## License
44
+
45
+ Licensed under the Apache License, Version 2.0.
@@ -2,33 +2,32 @@
2
2
 
3
3
  module RunApi
4
4
  module GptImage
5
- # GPT Image 1.5 image generation API client.
5
+ # GPT Image 1.5 generation and editing API client.
6
+ #
7
+ # Both aspect_ratio and quality are required for all operations.
6
8
  #
7
9
  # @example
8
10
  # client = RunApi::GptImage::Client.new(api_key: "your-api-key")
9
11
  #
10
12
  # # Text-to-image
11
13
  # result = client.text_to_image.run(
12
- # model: "gpt-image-1.5-text-to-image", prompt: "A futuristic cityscape"
14
+ # model: "gpt-image-1.5", prompt: "A futuristic cityscape"
13
15
  # )
14
16
  #
15
- # # Image-to-image
17
+ # # Edit image
16
18
  # edited = client.edit_image.run(
17
- # model: "gpt-image-1.5-image-to-image",
19
+ # model: "gpt-image-1.5",
18
20
  # prompt: "Transform into oil painting",
19
- # input_urls: ["https://example.com/photo.jpg"]
21
+ # source_image_urls: ["https://cdn.runapi.ai/public/samples/photo.jpg"]
20
22
  # )
21
- class Client
23
+ class Client < RunApi::Core::Client
22
24
  # @return [Resources::TextToImage] Text-to-image generation operations.
23
25
  attr_reader :text_to_image
24
- # @return [Resources::EditImage] Image-to-image edit operations.
26
+ # @return [Resources::EditImage] Image edit operations.
25
27
  attr_reader :edit_image
26
28
 
27
29
  def initialize(api_key: nil, **options)
28
- @api_key = Core::Auth.resolve_api_key(api_key)
29
-
30
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
31
- http = client_options.http_client || Core::HttpClient.new(client_options)
30
+ super
32
31
  @text_to_image = Resources::TextToImage.new(http)
33
32
  @edit_image = Resources::EditImage.new(http)
34
33
  end
@@ -3,7 +3,7 @@
3
3
  module RunApi
4
4
  module GptImage
5
5
  module Resources
6
- # GPT Image 1.5 image-to-image edit resource.
6
+ # GPT Image 1.5 image edit resource.
7
7
  class EditImage
8
8
  include RunApi::Core::ResourceHelpers
9
9
 
@@ -25,7 +25,7 @@ module RunApi
25
25
  poll_until_complete { get(task.id) }
26
26
  end
27
27
 
28
- # Create an image-to-image edit task.
28
+ # Create an image editing task.
29
29
  #
30
30
  # @param params [Hash] edit parameters
31
31
  # @return [RunApi::GptImage::Types::EditImageResponse] task creation result with id
@@ -54,9 +54,9 @@ module RunApi
54
54
  raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::EDIT_MODELS.join(", ")}"
55
55
  end
56
56
 
57
- urls = param(params, :input_urls)
57
+ urls = param(params, :source_image_urls)
58
58
  if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
59
- raise Core::ValidationError, "input_urls is required for image-to-image models"
59
+ raise Core::ValidationError, "source_image_urls is required for image editing"
60
60
  end
61
61
 
62
62
  raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
@@ -2,32 +2,39 @@
2
2
 
3
3
  module RunApi
4
4
  module GptImage
5
+ # Type definitions and constants for GPT Image 1.5.
6
+ # Both aspect_ratio and quality are required for all operations.
5
7
  module Types
6
- GENERATION_MODELS = %w[gpt-image-1.5-text-to-image].freeze
7
- EDIT_MODELS = %w[gpt-image-1.5-image-to-image].freeze
8
- MODELS = (GENERATION_MODELS + EDIT_MODELS).freeze
8
+ MODELS = %w[gpt-image-1.5].freeze
9
+ GENERATION_MODELS = MODELS
10
+ EDIT_MODELS = MODELS
9
11
 
12
+ # Required for all operations.
10
13
  ASPECT_RATIOS = %w[1:1 2:3 3:2].freeze
14
+ # Higher quality takes longer but produces finer detail.
11
15
  QUALITY_VALUES = %w[medium high].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 }
20
- optional :images, [ -> { Image } ]
26
+ optional :images, [-> { Image }]
21
27
  optional :error, String
22
28
  end
23
29
 
30
+ # Edit response -- same shape as generation.
24
31
  EditImageResponse = TextToImageResponse
25
32
 
26
33
  # Narrowed response returned by `run()` methods once polling observes
27
34
  # `status: "completed"`. `images` is required so consumers never have to
28
35
  # null-check it on a successful task.
29
36
  class CompletedTextToImageResponse < TextToImageResponse
30
- required :images, [ -> { Image } ]
37
+ required :images, [-> { Image }]
31
38
  end
32
39
 
33
40
  CompletedEditImageResponse = CompletedTextToImageResponse
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-gpt-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,22 +15,27 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.4
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.4
26
- description: RunAPI GPT Image SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.6
26
+ description: The gpt image api Ruby SDK is the language-specific package for GPT Image
27
+ on RunAPI. Use this gpt image api package for text-to-image, image editing, and
28
+ creative production flows when your application needs JSON request bodies, task
29
+ status lookup, and consistent RunAPI errors in Ruby.
27
30
  email:
28
31
  - contact@runapi.ai
29
32
  executables: []
30
33
  extensions: []
31
- extra_rdoc_files: []
34
+ extra_rdoc_files:
35
+ - README.md
32
36
  files:
33
37
  - LICENSE
38
+ - README.md
34
39
  - lib/runapi-gpt_image.rb
35
40
  - lib/runapi/gpt_image.rb
36
41
  - lib/runapi/gpt_image/client.rb
@@ -42,7 +47,7 @@ licenses:
42
47
  - Apache-2.0
43
48
  metadata:
44
49
  homepage_uri: https://runapi.ai/models/gpt-image
45
- documentation_uri: https://github.com/runapi-ai/gpt-image-sdk/blob/main/README.md
50
+ documentation_uri: https://github.com/runapi-ai/gpt-image-sdk/blob/main/ruby/README.md
46
51
  source_code_uri: https://github.com/runapi-ai/gpt-image-sdk
47
52
  changelog_uri: https://github.com/runapi-ai/gpt-image-sdk/blob/main/CHANGELOG.md
48
53
  rdoc_options: []
@@ -61,5 +66,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
66
  requirements: []
62
67
  rubygems_version: 4.0.10
63
68
  specification_version: 4
64
- summary: GPT Image API SDKs for JavaScript, Ruby, and Go on RunAPI.
69
+ summary: GPT Image API Ruby SDK for RunAPI
65
70
  test_files: []