runapi-gpt-image 0.2.6 → 0.2.8

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: cd933bb97d1ca6a8ccf0708928f4985b1cfb06aae5cef4ec9d65b8b84448d0b1
4
- data.tar.gz: cd13517224d400ec1f493166b6fc9ce4b6c479c967e14b680efa4f0c4f1db2f2
3
+ metadata.gz: 74662bacab7fb4a6dd1e7fe2967cbe5a581fcb87114277886ff7e05b314a4cf4
4
+ data.tar.gz: dccc18ba6f46ec68e1459b58bb8bc45be7ad626f64b0c3f3a4bdd156a139c4a9
5
5
  SHA512:
6
- metadata.gz: 2706384365717c217ffd71e4e654e92c1e24bb57318cd07cf7a420f78f1cb33a74faf19c0e01d6b30075e4d180204afc21cf66a5f6ce6f5a6f975d5eda50d3e6
7
- data.tar.gz: 2c3b05a82ff0868976e4c0c0277dd1b8baeb9364eb816da8989f7161a6b91a9a36aa9a882e78a8de055a8ed1812e62146098dfb74e5d75285896e41f3fe65b18
6
+ metadata.gz: 933dee7b56f26a5649f0ec03ed7e8c67c5a955483198a426a2a07187e5f361484315235affccb0ce8027bf2a854e23ce9a23f062b56c87293692cb563fa4d670
7
+ data.tar.gz: ba084d0db035a20d479b6053d36a7fdbc5819187da149baf095c34f4b20bfc631a1bbb3917af084512340c2e9cbf355a194dbae58e8f0ded1c890c1c34beab59
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # GPT Image API Ruby SDK for RunAPI
1
+ # GPT Image Ruby SDK for RunAPI
2
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.
3
+ The GPT Image Ruby SDK is the language-specific package for GPT Image on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
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.
5
+ This 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
6
 
7
7
  ## Install
8
8
 
@@ -13,13 +13,13 @@ gem install runapi-gpt-image
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-gpt-image"
16
+ require "runapi/gpt_image"
17
17
 
18
18
  client = RunApi::GptImage::Client.new
19
- task = client.generations.create(
19
+ task = client.text_to_image.create(
20
20
  # Pass the GPT Image JSON request body from https://runapi.ai/docs#gpt-image.
21
21
  )
22
- status = client.generations.get(task.id)
22
+ status = client.text_to_image.get(task.id)
23
23
  ```
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.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
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.
31
+ Use Ruby keyword arguments and the `RunApi::GptImage` error classes when building image jobs, Rails workers, or scripts. The available resources are `text_to_image` and `edit_image`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module GptImage
5
+ CONTRACT = {
6
+ "edit-image" => {
7
+ "models" => ["gpt-image-1.5"],
8
+ "fields_by_model" => {
9
+ "gpt-image-1.5" => {
10
+ "aspect_ratio" => {
11
+ "enum" => ["1:1", "2:3", "3:2"],
12
+ "required" => true
13
+ },
14
+ "prompt" => {
15
+ "required" => true
16
+ },
17
+ "quality" => {
18
+ "enum" => ["medium", "high"],
19
+ "required" => true
20
+ },
21
+ "source_image_urls" => {
22
+ "required" => true
23
+ }
24
+ }
25
+ }
26
+ },
27
+ "text-to-image" => {
28
+ "models" => ["gpt-image-1.5"],
29
+ "fields_by_model" => {
30
+ "gpt-image-1.5" => {
31
+ "aspect_ratio" => {
32
+ "enum" => ["1:1", "2:3", "3:2"],
33
+ "required" => true
34
+ },
35
+ "prompt" => {
36
+ "required" => true
37
+ },
38
+ "quality" => {
39
+ "enum" => ["medium", "high"],
40
+ "required" => true
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }.freeze
46
+ end
47
+ end
@@ -20,49 +20,27 @@ module RunApi
20
20
  #
21
21
  # @param params [Hash] edit parameters
22
22
  # @return [RunApi::GptImage::Types::CompletedEditImageResponse] completed edit with images
23
- def run(**params)
24
- task = create(**params)
25
- poll_until_complete { get(task.id) }
23
+ def run(options: nil, **params)
24
+ task = create(options: options, **params)
25
+ poll_until_complete { get(task.id, options: options) }
26
26
  end
27
27
 
28
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
32
- def create(**params)
32
+ def create(options: nil, **params)
33
33
  params = compact_params(params)
34
- validate_params!(params)
35
- request(:post, ENDPOINT, body: params)
34
+ validate_contract!(CONTRACT["edit-image"], params)
35
+ request(:post, ENDPOINT, body: params, options: options)
36
36
  end
37
37
 
38
38
  # Get edit status by task ID.
39
39
  #
40
40
  # @param id [String] task ID
41
41
  # @return [RunApi::GptImage::Types::EditImageResponse] current edit status
42
- def get(id)
43
- request(:get, "#{ENDPOINT}/#{id}")
44
- end
45
-
46
- private
47
-
48
- def validate_params!(params)
49
- raise Core::ValidationError, "model is required" unless param(params, :model)
50
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
51
-
52
- model = param(params, :model)
53
- unless Types::EDIT_MODELS.include?(model)
54
- raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::EDIT_MODELS.join(", ")}"
55
- end
56
-
57
- urls = param(params, :source_image_urls)
58
- if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
59
- raise Core::ValidationError, "source_image_urls is required for image editing"
60
- end
61
-
62
- raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
63
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
64
- raise Core::ValidationError, "quality is required" unless param(params, :quality)
65
- validate_optional!(params, :quality, Types::QUALITY_VALUES)
42
+ def get(id, options: nil)
43
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
66
44
  end
67
45
  end
68
46
  end
@@ -20,44 +20,27 @@ module RunApi
20
20
  #
21
21
  # @param params [Hash] generation parameters
22
22
  # @return [RunApi::GptImage::Types::CompletedTextToImageResponse] completed generation with images
23
- def run(**params)
24
- task = create(**params)
25
- poll_until_complete { get(task.id) }
23
+ def run(options: nil, **params)
24
+ task = create(options: options, **params)
25
+ poll_until_complete { get(task.id, options: options) }
26
26
  end
27
27
 
28
28
  # Create a text-to-image generation task.
29
29
  #
30
30
  # @param params [Hash] generation parameters
31
31
  # @return [RunApi::GptImage::Types::TextToImageResponse] task creation result with id
32
- def create(**params)
32
+ def create(options: nil, **params)
33
33
  params = compact_params(params)
34
- validate_params!(params)
35
- request(:post, ENDPOINT, body: params)
34
+ validate_contract!(CONTRACT["text-to-image"], params)
35
+ request(:post, ENDPOINT, body: params, options: options)
36
36
  end
37
37
 
38
38
  # Get generation status by task ID.
39
39
  #
40
40
  # @param id [String] task ID
41
41
  # @return [RunApi::GptImage::Types::TextToImageResponse] current generation status
42
- def get(id)
43
- request(:get, "#{ENDPOINT}/#{id}")
44
- end
45
-
46
- private
47
-
48
- def validate_params!(params)
49
- raise Core::ValidationError, "model is required" unless param(params, :model)
50
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
51
-
52
- model = param(params, :model)
53
- unless Types::GENERATION_MODELS.include?(model)
54
- raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::GENERATION_MODELS.join(", ")}"
55
- end
56
-
57
- raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
58
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
59
- raise Core::ValidationError, "quality is required" unless param(params, :quality)
60
- validate_optional!(params, :quality, Types::QUALITY_VALUES)
42
+ def get(id, options: nil)
43
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
61
44
  end
62
45
  end
63
46
  end
@@ -5,15 +5,6 @@ module RunApi
5
5
  # Type definitions and constants for GPT Image 1.5.
6
6
  # Both aspect_ratio and quality are required for all operations.
7
7
  module Types
8
- MODELS = %w[gpt-image-1.5].freeze
9
- GENERATION_MODELS = MODELS
10
- EDIT_MODELS = MODELS
11
-
12
- # Required for all operations.
13
- ASPECT_RATIOS = %w[1:1 2:3 3:2].freeze
14
- # Higher quality takes longer but produces finer detail.
15
- QUALITY_VALUES = %w[medium high].freeze
16
-
17
8
  # A single generated image with its CDN URL.
18
9
  class Image < RunApi::Core::BaseModel
19
10
  optional :url, String
@@ -23,6 +14,7 @@ module RunApi
23
14
  class TextToImageResponse < RunApi::Core::TaskResponse
24
15
  required :id, String
25
16
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
17
+ optional :task_replayed
26
18
  optional :images, [-> { Image }]
27
19
  optional :error, String
28
20
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "gpt_image/types"
5
+ require_relative "gpt_image/contract_gen"
5
6
  require_relative "gpt_image/resources/text_to_image"
6
7
  require_relative "gpt_image/resources/edit_image"
7
8
  require_relative "gpt_image/client"
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.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,18 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.3.0
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.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.
25
+ version: 0.3.0
26
+ description: The GPT Image Ruby SDK is the language-specific package for GPT Image
27
+ on RunAPI. Use this package for image generation, image editing, and creative production
28
+ workflows when your application needs request bodies, task status lookup, and consistent
29
+ RunAPI errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - lib/runapi-gpt_image.rb
40
40
  - lib/runapi/gpt_image.rb
41
41
  - lib/runapi/gpt_image/client.rb
42
+ - lib/runapi/gpt_image/contract_gen.rb
42
43
  - lib/runapi/gpt_image/resources/edit_image.rb
43
44
  - lib/runapi/gpt_image/resources/text_to_image.rb
44
45
  - lib/runapi/gpt_image/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/gpt-image
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: gpt-image
49
51
  homepage_uri: https://runapi.ai/models/gpt-image
50
52
  documentation_uri: https://github.com/runapi-ai/gpt-image-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/gpt-image-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/gpt-image-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/gpt-image-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  - !ruby/object:Gem::Version
65
68
  version: '0'
66
69
  requirements: []
67
- rubygems_version: 4.0.10
70
+ rubygems_version: 4.0.17
68
71
  specification_version: 4
69
- summary: GPT Image API Ruby SDK for RunAPI
72
+ summary: GPT Image Ruby SDK for RunAPI
70
73
  test_files: []