runapi-gpt-image-2 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7664913b3073c7ef5cec93d7661a89f41df732140b1bb741f558b37a0c707484
|
|
4
|
+
data.tar.gz: ed6c4be520bcaaab01bf5a20be19cff0947ca1951c961fb8eae93a9713a62007
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: deeb9ac2db537db1101e79fe045c5906aac1b4e573f13dedf01dd562001e8047869612e2f5a0fcd5f80aafe9eae81a0ffe8580ce71930011d722439b06495b5b
|
|
7
|
+
data.tar.gz: 223abf29ac0d43b6c71113101e69b050c8618471c934c5c0a0d900c7718f3fe3612e5888213ddc1ae8530bab3528b1ac19c5949da121069c27cfe64015efa027
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# GPT Image 2 API Ruby SDK for RunAPI
|
|
2
|
+
|
|
3
|
+
The gpt image 2 api Ruby SDK is the language-specific package for GPT Image 2 on RunAPI. Use this gpt image 2 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 2 api 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
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem install runapi-gpt-image-2
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require "runapi-gpt-image-2"
|
|
17
|
+
|
|
18
|
+
client = RunApi::GptImage2::Client.new
|
|
19
|
+
task = client.generations.create(
|
|
20
|
+
# Pass the GPT Image 2 JSON request body from https://runapi.ai/docs#gpt-image-2.
|
|
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::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.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- Model page: https://runapi.ai/models/gpt-image-2
|
|
36
|
+
- SDK docs: https://runapi.ai/docs#sdk-gpt-image-2
|
|
37
|
+
- Product docs: https://runapi.ai/docs#gpt-image-2
|
|
38
|
+
- Pricing and rate limits: https://runapi.ai/models/gpt-image-2/text-to-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-2-sdk
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -2,14 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module GptImage2
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -41,12 +43,13 @@ module RunApi
|
|
|
41
43
|
raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::EDIT_MODELS.join(", ")}"
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
urls = param(params, :
|
|
46
|
+
urls = param(params, :source_image_urls)
|
|
45
47
|
if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
|
|
46
|
-
raise Core::ValidationError, "
|
|
48
|
+
raise Core::ValidationError, "source_image_urls is required for edit image requests"
|
|
47
49
|
end
|
|
48
50
|
|
|
49
51
|
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
52
|
+
validate_optional!(params, :output_resolution, Types::RESOLUTIONS)
|
|
50
53
|
end
|
|
51
54
|
end
|
|
52
55
|
end
|
|
@@ -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
|
|
|
@@ -42,6 +44,7 @@ module RunApi
|
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
47
|
+
validate_optional!(params, :output_resolution, Types::RESOLUTIONS)
|
|
45
48
|
end
|
|
46
49
|
end
|
|
47
50
|
end
|
|
@@ -2,28 +2,37 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
MODELS = %w[gpt-image-2].freeze
|
|
9
|
+
GENERATION_MODELS = MODELS
|
|
10
|
+
EDIT_MODELS = MODELS
|
|
9
11
|
|
|
10
|
-
|
|
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
|
|
11
16
|
|
|
17
|
+
# A single generated image with its CDN URL.
|
|
12
18
|
class Image < RunApi::Core::BaseModel
|
|
13
19
|
optional :url, String
|
|
14
20
|
end
|
|
15
21
|
|
|
22
|
+
# Generation result. +images+ is populated once +status+ is +"completed"+.
|
|
16
23
|
class TextToImageResponse < RunApi::Core::TaskResponse
|
|
17
24
|
required :id, String
|
|
18
25
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
19
|
-
optional :images, [
|
|
26
|
+
optional :images, [-> { Image }]
|
|
20
27
|
optional :error, String
|
|
21
28
|
end
|
|
22
29
|
|
|
30
|
+
# Edit response -- same shape as generation.
|
|
23
31
|
EditImageResponse = TextToImageResponse
|
|
24
32
|
|
|
33
|
+
# Narrowed response from +run()+ where +images+ is guaranteed present.
|
|
25
34
|
class CompletedTextToImageResponse < TextToImageResponse
|
|
26
|
-
required :images, [
|
|
35
|
+
required :images, [-> { Image }]
|
|
27
36
|
end
|
|
28
37
|
|
|
29
38
|
CompletedEditImageResponse = CompletedTextToImageResponse
|
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.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.
|
|
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.
|
|
26
|
-
description:
|
|
25
|
+
version: 0.2.6
|
|
26
|
+
description: The gpt image 2 api Ruby SDK is the language-specific package for GPT
|
|
27
|
+
Image 2 on RunAPI. Use this gpt image 2 api package for text-to-image, image editing,
|
|
28
|
+
and 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_2.rb
|
|
35
40
|
- lib/runapi/gpt_image_2.rb
|
|
36
41
|
- lib/runapi/gpt_image_2/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-2
|
|
45
|
-
documentation_uri: https://github.com/runapi-ai/gpt-image-2-sdk/blob/main/README.md
|
|
50
|
+
documentation_uri: https://github.com/runapi-ai/gpt-image-2-sdk/blob/main/ruby/README.md
|
|
46
51
|
source_code_uri: https://github.com/runapi-ai/gpt-image-2-sdk
|
|
47
52
|
changelog_uri: https://github.com/runapi-ai/gpt-image-2-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 2 API
|
|
69
|
+
summary: GPT Image 2 API Ruby SDK for RunAPI
|
|
65
70
|
test_files: []
|