runapi-gpt-4o-image 0.2.5 → 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 +10 -8
- data/lib/runapi/gpt_4o_image/client.rb +23 -5
- data/lib/runapi/gpt_4o_image/contract_gen.rb +23 -0
- data/lib/runapi/gpt_4o_image/resources/text_to_image.rb +3 -16
- data/lib/runapi/gpt_4o_image/types.rb +5 -4
- data/lib/runapi/gpt_4o_image.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: 0bde0a1009adf492967f5a45e2f602da47664e435d83938704a262709c1bc8ea
|
|
4
|
+
data.tar.gz: efe6d98d743b8801b266885e4bc57e21d838727547179d1dc20af0a324832908
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61889c9a5c4c2fc6bdf33eeba1f76faeb171df8ff2343ca1c29cf51a5984aa3897e476f18cb28c59921096878261ae8547fb21518d9c99153a8036875655b951
|
|
7
|
+
data.tar.gz: dd3efdf22b6f1e8e8ec7525d1b72a5a14d8b4ad2e5f71296aac2ffd8043d911b51f604b0c8dd434a2fbaab65b123406c0c11c11e8baadae035fb49f2cdfc7208
|
data/README.md
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
# GPT-4o Image
|
|
1
|
+
# GPT-4o Image Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The GPT-4o Image Ruby SDK is the language-specific package for GPT-4o 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
|
|
5
|
+
This README is the Ruby package guide inside the public `gpt-4o-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/gpt-4o-image; for API reference, use https://runapi.ai/docs#gpt-4o-image; for SDK docs, use https://runapi.ai/docs#sdk-gpt-4o-image.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
gem install runapi-
|
|
10
|
+
gem install runapi-gpt-4o-image
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
require "runapi-
|
|
16
|
+
require "runapi-gpt-4o-image"
|
|
17
17
|
|
|
18
18
|
client = RunApi::Gpt4oImage::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.text_to_image.create(
|
|
20
20
|
# Pass the GPT-4o Image JSON request body from https://runapi.ai/docs#gpt-4o-image.
|
|
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.
|
|
26
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
|
+
|
|
27
29
|
## Language notes
|
|
28
30
|
|
|
29
|
-
Use Ruby keyword arguments and the `RunApi::Gpt4oImage` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::Gpt4oImage` error classes when building image jobs, Rails workers, or scripts. The available resources are `text_to_image`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
30
32
|
|
|
31
33
|
## Links
|
|
32
34
|
|
|
@@ -2,14 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Gpt4oImage
|
|
5
|
-
|
|
5
|
+
# GPT-4o Image generation and editing API client.
|
|
6
|
+
#
|
|
7
|
+
# Supports pure text-to-image generation, image editing with source images,
|
|
8
|
+
# and inpainting with an optional mask.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# client = RunApi::Gpt4oImage::Client.new(api_key: "your-api-key")
|
|
12
|
+
#
|
|
13
|
+
# # Pure generation
|
|
14
|
+
# result = client.text_to_image.run(
|
|
15
|
+
# model: "gpt-4o-image", prompt: "A mountain lake at dawn",
|
|
16
|
+
# aspect_ratio: "3:2"
|
|
17
|
+
# )
|
|
18
|
+
#
|
|
19
|
+
# # Edit with source images
|
|
20
|
+
# edited = client.text_to_image.run(
|
|
21
|
+
# model: "gpt-4o-image", prompt: "Add a rainbow",
|
|
22
|
+
# aspect_ratio: "3:2",
|
|
23
|
+
# source_image_urls: ["https://cdn.runapi.ai/public/samples/image.jpg"]
|
|
24
|
+
# )
|
|
25
|
+
class Client < RunApi::Core::Client
|
|
26
|
+
# @return [Resources::TextToImage] Image generation and editing operations.
|
|
6
27
|
attr_reader :text_to_image
|
|
7
28
|
|
|
8
29
|
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)
|
|
30
|
+
super
|
|
13
31
|
@text_to_image = Resources::TextToImage.new(http)
|
|
14
32
|
end
|
|
15
33
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Gpt4oImage
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"text-to-image" => {
|
|
7
|
+
"models" => ["gpt-4o-image"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"gpt-4o-image" => {
|
|
10
|
+
"aspect_ratio" => {
|
|
11
|
+
"enum" => ["1:1", "3:2", "2:3"],
|
|
12
|
+
"required" => true
|
|
13
|
+
},
|
|
14
|
+
"output_count" => {
|
|
15
|
+
"enum" => [1, 2, 4],
|
|
16
|
+
"type" => "integer"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}.freeze
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Gpt4oImage
|
|
5
5
|
module Resources
|
|
6
|
+
# GPT-4o Image generation and editing resource.
|
|
7
|
+
# Generate images from text, edit with source images, or inpaint with a mask.
|
|
6
8
|
class TextToImage
|
|
7
9
|
include RunApi::Core::ResourceHelpers
|
|
8
10
|
|
|
@@ -22,28 +24,13 @@ module RunApi
|
|
|
22
24
|
|
|
23
25
|
def create(**params)
|
|
24
26
|
params = compact_params(params)
|
|
25
|
-
|
|
27
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
26
28
|
request(:post, ENDPOINT, body: params)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def get(id)
|
|
30
32
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
31
33
|
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def validate_params!(params)
|
|
36
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
37
|
-
raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
|
|
38
|
-
|
|
39
|
-
model = param(params, :model)
|
|
40
|
-
unless Types::MODELS.include?(model)
|
|
41
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::MODELS.join(", ")}"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
45
|
-
validate_optional!(params, :output_count, Types::OUTPUT_COUNTS)
|
|
46
|
-
end
|
|
47
34
|
end
|
|
48
35
|
end
|
|
49
36
|
end
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Gpt4oImage
|
|
5
|
+
# GPT-4o Image response models.
|
|
6
|
+
# Supports pure generation, editing with source images, and inpainting with a mask.
|
|
5
7
|
module Types
|
|
6
|
-
|
|
7
|
-
ASPECT_RATIOS = %w[1:1 3:2 2:3].freeze
|
|
8
|
-
OUTPUT_COUNTS = [1, 2, 4].freeze
|
|
9
|
-
|
|
8
|
+
# A generated image with its CDN URL.
|
|
10
9
|
class Image < RunApi::Core::BaseModel
|
|
11
10
|
optional :url, String
|
|
12
11
|
end
|
|
13
12
|
|
|
13
|
+
# Response for GPT-4o Image tasks. Progress contains an intermediate
|
|
14
|
+
# status string while the task is running.
|
|
14
15
|
class TextToImageResponse < RunApi::Core::TaskResponse
|
|
15
16
|
required :id, String
|
|
16
17
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
data/lib/runapi/gpt_4o_image.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-gpt-4o-image
|
|
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
|
-
Image on RunAPI. Use this
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
version: 0.2.7
|
|
26
|
+
description: The GPT-4o Image Ruby SDK is the language-specific package for GPT-4o
|
|
27
|
+
Image 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,15 +39,18 @@ files:
|
|
|
39
39
|
- lib/runapi-gpt_4o_image.rb
|
|
40
40
|
- lib/runapi/gpt_4o_image.rb
|
|
41
41
|
- lib/runapi/gpt_4o_image/client.rb
|
|
42
|
+
- lib/runapi/gpt_4o_image/contract_gen.rb
|
|
42
43
|
- lib/runapi/gpt_4o_image/resources/text_to_image.rb
|
|
43
44
|
- lib/runapi/gpt_4o_image/types.rb
|
|
44
45
|
homepage: https://runapi.ai/models/gpt-4o-image
|
|
45
46
|
licenses:
|
|
46
47
|
- Apache-2.0
|
|
47
48
|
metadata:
|
|
49
|
+
runapi_slug: gpt-4o-image
|
|
48
50
|
homepage_uri: https://runapi.ai/models/gpt-4o-image
|
|
49
51
|
documentation_uri: https://github.com/runapi-ai/gpt-4o-image-sdk/blob/main/ruby/README.md
|
|
50
52
|
source_code_uri: https://github.com/runapi-ai/gpt-4o-image-sdk
|
|
53
|
+
bug_tracker_uri: https://github.com/runapi-ai/gpt-4o-image-sdk/issues
|
|
51
54
|
changelog_uri: https://github.com/runapi-ai/gpt-4o-image-sdk/blob/main/CHANGELOG.md
|
|
52
55
|
rdoc_options: []
|
|
53
56
|
require_paths:
|
|
@@ -65,5 +68,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
68
|
requirements: []
|
|
66
69
|
rubygems_version: 4.0.10
|
|
67
70
|
specification_version: 4
|
|
68
|
-
summary: GPT-4o Image
|
|
71
|
+
summary: GPT-4o Image Ruby SDK for RunAPI
|
|
69
72
|
test_files: []
|