runapi-gpt-image-2 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 +4 -4
- data/README.md +6 -6
- data/lib/runapi/gpt_image_2/client.rb +1 -1
- data/lib/runapi/gpt_image_2/contract_gen.rb +43 -0
- data/lib/runapi/gpt_image_2/resources/edit_image.rb +1 -21
- data/lib/runapi/gpt_image_2/resources/text_to_image.rb +1 -16
- data/lib/runapi/gpt_image_2/types.rb +1 -11
- data/lib/runapi/gpt_image_2.rb +1 -0
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e679c62e55353ec2c36187098975de7770b69c8407f994aacdb5ea17a794c351
|
|
4
|
+
data.tar.gz: 9286a4d151ae82e9df3b045f1c241b4c738bac936c550c8bcfc4b9cf3b2e5d67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb53d80ad81e29e7339bfb845b78fb50f9554d62473559609999deac7c2f55ecebb5041ce296cafe7db807dfd9dab2c8463baaeb35a5b372a27e6b6dfefd29c8
|
|
7
|
+
data.tar.gz: 3685800e58e240512d0533f895ede39d1445c2f00971442aa6000e6b1f3d7ee8c21a2289bec4a49955b81706cd3a33b6f82802859be7fbec8ed47e4e81de014e
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# GPT Image 2
|
|
1
|
+
# GPT Image 2 Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The GPT Image 2 Ruby SDK is the language-specific package for GPT Image 2 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
|
|
5
|
+
This README is the Ruby package guide inside the public `gpt-image-2-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/gpt-image-2; for API reference, use https://runapi.ai/docs#gpt-image-2; for SDK docs, use https://runapi.ai/docs#sdk-gpt-image-2.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,10 +16,10 @@ gem install runapi-gpt-image-2
|
|
|
16
16
|
require "runapi-gpt-image-2"
|
|
17
17
|
|
|
18
18
|
client = RunApi::GptImage2::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.text_to_image.create(
|
|
20
20
|
# Pass the GPT Image 2 JSON request body from https://runapi.ai/docs#gpt-image-2.
|
|
21
21
|
)
|
|
22
|
-
status = client.
|
|
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::GptImage2` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::GptImage2` 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
|
|
|
@@ -17,7 +17,7 @@ module RunApi
|
|
|
17
17
|
# # Edit image
|
|
18
18
|
# edited = client.edit_image.run(
|
|
19
19
|
# model: "gpt-image-2", prompt: "Transform into oil painting",
|
|
20
|
-
# source_image_urls: ["https://
|
|
20
|
+
# source_image_urls: ["https://cdn.runapi.ai/public/samples/image.jpg"]
|
|
21
21
|
# )
|
|
22
22
|
class Client < RunApi::Core::Client
|
|
23
23
|
# @return [Resources::TextToImage] Text-to-image generation operations.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module GptImage2
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"edit-image" => {
|
|
7
|
+
"models" => ["gpt-image-2"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"gpt-image-2" => {
|
|
10
|
+
"aspect_ratio" => {
|
|
11
|
+
"enum" => ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5", "16:9", "9:16", "2:1", "1:2", "3:1", "1:3", "21:9", "9:21"]
|
|
12
|
+
},
|
|
13
|
+
"output_resolution" => {
|
|
14
|
+
"enum" => ["1k", "2k", "4k"]
|
|
15
|
+
},
|
|
16
|
+
"prompt" => {
|
|
17
|
+
"required" => true
|
|
18
|
+
},
|
|
19
|
+
"source_image_urls" => {
|
|
20
|
+
"required" => true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"text-to-image" => {
|
|
26
|
+
"models" => ["gpt-image-2"],
|
|
27
|
+
"fields_by_model" => {
|
|
28
|
+
"gpt-image-2" => {
|
|
29
|
+
"aspect_ratio" => {
|
|
30
|
+
"enum" => ["auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5", "16:9", "9:16", "2:1", "1:2", "3:1", "1:3", "21:9", "9:21"]
|
|
31
|
+
},
|
|
32
|
+
"output_resolution" => {
|
|
33
|
+
"enum" => ["1k", "2k", "4k"]
|
|
34
|
+
},
|
|
35
|
+
"prompt" => {
|
|
36
|
+
"required" => true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}.freeze
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -24,33 +24,13 @@ module RunApi
|
|
|
24
24
|
|
|
25
25
|
def create(**params)
|
|
26
26
|
params = compact_params(params)
|
|
27
|
-
|
|
27
|
+
validate_contract!(CONTRACT["edit-image"], params)
|
|
28
28
|
request(:post, ENDPOINT, body: params)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def get(id)
|
|
32
32
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def validate_params!(params)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
39
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
40
|
-
|
|
41
|
-
model = param(params, :model)
|
|
42
|
-
unless Types::EDIT_MODELS.include?(model)
|
|
43
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::EDIT_MODELS.join(", ")}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
urls = param(params, :source_image_urls)
|
|
47
|
-
if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
|
|
48
|
-
raise Core::ValidationError, "source_image_urls is required for edit image requests"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
52
|
-
validate_optional!(params, :output_resolution, Types::RESOLUTIONS)
|
|
53
|
-
end
|
|
54
34
|
end
|
|
55
35
|
end
|
|
56
36
|
end
|
|
@@ -24,28 +24,13 @@ module RunApi
|
|
|
24
24
|
|
|
25
25
|
def create(**params)
|
|
26
26
|
params = compact_params(params)
|
|
27
|
-
|
|
27
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
28
28
|
request(:post, ENDPOINT, body: params)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def get(id)
|
|
32
32
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def validate_params!(params)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
39
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
40
|
-
|
|
41
|
-
model = param(params, :model)
|
|
42
|
-
unless Types::GENERATION_MODELS.include?(model)
|
|
43
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::GENERATION_MODELS.join(", ")}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
47
|
-
validate_optional!(params, :output_resolution, Types::RESOLUTIONS)
|
|
48
|
-
end
|
|
49
34
|
end
|
|
50
35
|
end
|
|
51
36
|
end
|
|
@@ -2,18 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module GptImage2
|
|
5
|
-
# Type definitions
|
|
6
|
-
# Unlike GPT Image 1.5, aspect_ratio and output_resolution are optional.
|
|
5
|
+
# Type definitions for GPT Image 2.
|
|
7
6
|
module Types
|
|
8
|
-
MODELS = %w[gpt-image-2].freeze
|
|
9
|
-
GENERATION_MODELS = MODELS
|
|
10
|
-
EDIT_MODELS = MODELS
|
|
11
|
-
|
|
12
|
-
# 'auto' lets the model choose based on the prompt content.
|
|
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.
|
|
15
|
-
RESOLUTIONS = %w[1k 2k 4k].freeze
|
|
16
|
-
|
|
17
7
|
# A single generated image with its CDN URL.
|
|
18
8
|
class Image < RunApi::Core::BaseModel
|
|
19
9
|
optional :url, String
|
data/lib/runapi/gpt_image_2.rb
CHANGED
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.
|
|
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.
|
|
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.
|
|
26
|
-
description: The
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
version: 0.2.7
|
|
26
|
+
description: The GPT Image 2 Ruby SDK is the language-specific package for GPT Image
|
|
27
|
+
2 on RunAPI. Use this package for image generation, image editing, and creative
|
|
28
|
+
production workflows when your application needs request bodies, task status lookup,
|
|
29
|
+
and consistent 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_2.rb
|
|
40
40
|
- lib/runapi/gpt_image_2.rb
|
|
41
41
|
- lib/runapi/gpt_image_2/client.rb
|
|
42
|
+
- lib/runapi/gpt_image_2/contract_gen.rb
|
|
42
43
|
- lib/runapi/gpt_image_2/resources/edit_image.rb
|
|
43
44
|
- lib/runapi/gpt_image_2/resources/text_to_image.rb
|
|
44
45
|
- lib/runapi/gpt_image_2/types.rb
|
|
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/gpt-image-2
|
|
|
46
47
|
licenses:
|
|
47
48
|
- Apache-2.0
|
|
48
49
|
metadata:
|
|
50
|
+
runapi_slug: gpt-image-2
|
|
49
51
|
homepage_uri: https://runapi.ai/models/gpt-image-2
|
|
50
52
|
documentation_uri: https://github.com/runapi-ai/gpt-image-2-sdk/blob/main/ruby/README.md
|
|
51
53
|
source_code_uri: https://github.com/runapi-ai/gpt-image-2-sdk
|
|
54
|
+
bug_tracker_uri: https://github.com/runapi-ai/gpt-image-2-sdk/issues
|
|
52
55
|
changelog_uri: https://github.com/runapi-ai/gpt-image-2-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 2
|
|
72
|
+
summary: GPT Image 2 Ruby SDK for RunAPI
|
|
70
73
|
test_files: []
|