runapi-gpt-image 0.2.6 → 0.2.7

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: aefd21d6faae0bc4b3b8d5233eeef9015c8377a2aba2e2ab0414aeae082ce8bd
4
+ data.tar.gz: 80a91ab1e6a9066e61cac383a2e241396b09274052c8db4f234d35d44d322d10
5
5
  SHA512:
6
- metadata.gz: 2706384365717c217ffd71e4e654e92c1e24bb57318cd07cf7a420f78f1cb33a74faf19c0e01d6b30075e4d180204afc21cf66a5f6ce6f5a6f975d5eda50d3e6
7
- data.tar.gz: 2c3b05a82ff0868976e4c0c0277dd1b8baeb9364eb816da8989f7161a6b91a9a36aa9a882e78a8de055a8ed1812e62146098dfb74e5d75285896e41f3fe65b18
6
+ metadata.gz: 6eadbfd617f632ed1ef9c989884b80782a6fe3ca5ac64ec5d9e6f48e515d7d51d5ba6ec8d4f6bd1c2a7cba62949575872eb00be0eb53901b05327a48c8ff0213
7
+ data.tar.gz: 3083b5683b15cf97eba4ae9c7a5cef84b49f6ab16bfe4a9112f136a59b84d57a83ade4df34b18354882d901c2b308c953e81d4bb6aa71533cc300372b7aa6936
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
 
@@ -16,10 +16,10 @@ gem install runapi-gpt-image
16
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
@@ -31,7 +31,7 @@ module RunApi
31
31
  # @return [RunApi::GptImage::Types::EditImageResponse] task creation result with id
32
32
  def create(**params)
33
33
  params = compact_params(params)
34
- validate_params!(params)
34
+ validate_contract!(CONTRACT["edit-image"], params)
35
35
  request(:post, ENDPOINT, body: params)
36
36
  end
37
37
 
@@ -42,28 +42,6 @@ module RunApi
42
42
  def get(id)
43
43
  request(:get, "#{ENDPOINT}/#{id}")
44
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)
66
- end
67
45
  end
68
46
  end
69
47
  end
@@ -31,7 +31,7 @@ module RunApi
31
31
  # @return [RunApi::GptImage::Types::TextToImageResponse] task creation result with id
32
32
  def create(**params)
33
33
  params = compact_params(params)
34
- validate_params!(params)
34
+ validate_contract!(CONTRACT["text-to-image"], params)
35
35
  request(:post, ENDPOINT, body: params)
36
36
  end
37
37
 
@@ -42,23 +42,6 @@ module RunApi
42
42
  def get(id)
43
43
  request(:get, "#{ENDPOINT}/#{id}")
44
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)
61
- end
62
45
  end
63
46
  end
64
47
  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
@@ -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.7
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.2.7
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.2.7
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:
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements: []
67
70
  rubygems_version: 4.0.10
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: []