runapi-gpt-image 0.2.4 → 0.2.5
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 +43 -0
- data/lib/runapi/gpt_image/client.rb +5 -5
- data/lib/runapi/gpt_image/resources/edit_image.rb +4 -4
- data/lib/runapi/gpt_image/types.rb +5 -5
- metadata +12 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f0f24d53e5a9bb71de80a322a18692628ce317bd934ef4b940be87f7b89c214
|
|
4
|
+
data.tar.gz: 34900b290a2914977d76d8c436fd8f2cdd9486583bbf9e9f68d45b09059accee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 607cb5ba0c1ab470b6851667c0cba9567a1ee79e3dcd314eeb5c76563f555fd861c5428fb5695045c98560d98a5c9ca4e1a05c120cd972c290d5df8d988a8db7
|
|
7
|
+
data.tar.gz: 26386b6c23a5a82143d3e9acc2ef9e28fd0340c35aade98202a819796c5ae3ec1f91f21f1788b17540207c276d567de8aaa1a71bcf895a78c2e0e2414f60cea3
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
## Language notes
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
## Links
|
|
32
|
+
|
|
33
|
+
- Model page: https://runapi.ai/models/gpt-image
|
|
34
|
+
- SDK docs: https://runapi.ai/docs#sdk-gpt-image
|
|
35
|
+
- Product docs: https://runapi.ai/docs#gpt-image
|
|
36
|
+
- Pricing and rate limits: https://runapi.ai/models/gpt-image
|
|
37
|
+
- Provider comparison: https://runapi.ai/providers/openai
|
|
38
|
+
- Full catalog: https://runapi.ai/models
|
|
39
|
+
- Repository: https://github.com/runapi-ai/gpt-image-sdk
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -9,19 +9,19 @@ module RunApi
|
|
|
9
9
|
#
|
|
10
10
|
# # Text-to-image
|
|
11
11
|
# result = client.text_to_image.run(
|
|
12
|
-
# model: "gpt-image-1.5
|
|
12
|
+
# model: "gpt-image-1.5", prompt: "A futuristic cityscape"
|
|
13
13
|
# )
|
|
14
14
|
#
|
|
15
|
-
# #
|
|
15
|
+
# # Edit image
|
|
16
16
|
# edited = client.edit_image.run(
|
|
17
|
-
# model: "gpt-image-1.5
|
|
17
|
+
# model: "gpt-image-1.5",
|
|
18
18
|
# prompt: "Transform into oil painting",
|
|
19
|
-
#
|
|
19
|
+
# source_image_urls: ["https://cdn.runapi.ai/public/samples/photo.jpg"]
|
|
20
20
|
# )
|
|
21
21
|
class Client
|
|
22
22
|
# @return [Resources::TextToImage] Text-to-image generation operations.
|
|
23
23
|
attr_reader :text_to_image
|
|
24
|
-
# @return [Resources::EditImage] Image
|
|
24
|
+
# @return [Resources::EditImage] Image edit operations.
|
|
25
25
|
attr_reader :edit_image
|
|
26
26
|
|
|
27
27
|
def initialize(api_key: nil, **options)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module GptImage
|
|
5
5
|
module Resources
|
|
6
|
-
# GPT Image 1.5 image
|
|
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
|
|
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, :
|
|
57
|
+
urls = param(params, :source_image_urls)
|
|
58
58
|
if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
|
|
59
|
-
raise Core::ValidationError, "
|
|
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)
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module GptImage
|
|
5
5
|
module Types
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
MODELS = %w[gpt-image-1.5].freeze
|
|
7
|
+
GENERATION_MODELS = MODELS
|
|
8
|
+
EDIT_MODELS = MODELS
|
|
9
9
|
|
|
10
10
|
ASPECT_RATIOS = %w[1:1 2:3 3:2].freeze
|
|
11
11
|
QUALITY_VALUES = %w[medium high].freeze
|
|
@@ -17,7 +17,7 @@ module RunApi
|
|
|
17
17
|
class TextToImageResponse < RunApi::Core::TaskResponse
|
|
18
18
|
required :id, String
|
|
19
19
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
20
|
-
optional :images, [
|
|
20
|
+
optional :images, [-> { Image }]
|
|
21
21
|
optional :error, String
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ module RunApi
|
|
|
27
27
|
# `status: "completed"`. `images` is required so consumers never have to
|
|
28
28
|
# null-check it on a successful task.
|
|
29
29
|
class CompletedTextToImageResponse < TextToImageResponse
|
|
30
|
-
required :images, [
|
|
30
|
+
required :images, [-> { Image }]
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
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
|
+
version: 0.2.5
|
|
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.5
|
|
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.5
|
|
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
|
|
69
|
+
summary: GPT Image API Ruby SDK for RunAPI
|
|
65
70
|
test_files: []
|