runapi-ideogram-v3 0.2.6 → 0.2.8
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 -4
- data/lib/runapi/ideogram_v3/client.rb +13 -10
- data/lib/runapi/ideogram_v3/contract_gen.rb +175 -0
- data/lib/runapi/ideogram_v3/resources/edit_image.rb +9 -23
- data/lib/runapi/ideogram_v3/resources/reframe_image.rb +9 -26
- data/lib/runapi/ideogram_v3/resources/remix_image.rb +9 -24
- data/lib/runapi/ideogram_v3/resources/text_to_image.rb +9 -25
- data/lib/runapi/ideogram_v3/types.rb +5 -10
- data/lib/runapi/ideogram_v3.rb +1 -0
- metadata +12 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9add18ecc621c7606bbd4f372ffa5ca4f95b1c889404ae120a7e1f50dc4eab27
|
|
4
|
+
data.tar.gz: 1fc686288d8ae18eb75fac174d46ab7eda7859d957e2ef55a6311028adb99d14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46995c95f202b96d5b9ef61a86161f61267f4e73a4df1f437e8f8999a43028c982acb1a7846f26c8c2fa574dd671fa670437935be98819c2788af432816c0b9d
|
|
7
|
+
data.tar.gz: 9babe9fe93c2469047f53bbc8691fb8eb142bddc6a100491ab52bc302b0b51da32136664b7afd20171109c4790a160af9fda60fd79cdc81e720d2b69de20c155
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Ideogram API Ruby SDK for RunAPI
|
|
1
|
+
# Ideogram V3 API Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Ideogram V3 Ruby SDK is the language-specific package for Ideogram V3 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 `ideogram-v3-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/ideogram-v3; for API reference, use https://runapi.ai/docs#ideogram-v3; for SDK docs, use https://runapi.ai/docs#sdk-ideogram-v3.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ gem install runapi-ideogram-v3
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
require "runapi
|
|
16
|
+
require "runapi/ideogram_v3"
|
|
17
17
|
|
|
18
18
|
client = RunApi::IdeogramV3::Client.new
|
|
19
19
|
task = client.text_to_image.create(
|
|
@@ -25,6 +25,8 @@ status = client.text_to_image.get(task.id)
|
|
|
25
25
|
|
|
26
26
|
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.
|
|
27
27
|
|
|
28
|
+
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.
|
|
29
|
+
|
|
28
30
|
## Language notes
|
|
29
31
|
|
|
30
32
|
Use Ruby keyword arguments and the `RunApi::IdeogramV3` error classes when building image jobs, Rails workers, or scripts. The available resources are `text_to_image`, `edit_image`, `remix_image`, and `reframe_image`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
@@ -4,24 +4,27 @@ module RunApi
|
|
|
4
4
|
module IdeogramV3
|
|
5
5
|
# Ideogram V3 image generation API client.
|
|
6
6
|
#
|
|
7
|
+
# Supports text-to-image, inpaint editing, remix, and reframe operations.
|
|
8
|
+
# Character model variants add character consistency from reference images.
|
|
9
|
+
#
|
|
7
10
|
# @example
|
|
8
11
|
# client = RunApi::IdeogramV3::Client.new(api_key: "your-api-key")
|
|
9
12
|
# result = client.text_to_image.run(
|
|
10
13
|
# model: "ideogram-v3-text-to-image",
|
|
11
14
|
# prompt: "A cinematic lakeside at twilight"
|
|
12
15
|
# )
|
|
13
|
-
class Client
|
|
14
|
-
# @return [Resources::TextToImage] Text-to-image operations.
|
|
15
|
-
|
|
16
|
-
# @return [Resources::
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
class Client < RunApi::Core::Client
|
|
17
|
+
# @return [Resources::TextToImage] Text-to-image generation operations.
|
|
18
|
+
attr_reader :text_to_image
|
|
19
|
+
# @return [Resources::EditImage] Inpaint-with-mask editing operations.
|
|
20
|
+
attr_reader :edit_image
|
|
21
|
+
# @return [Resources::RemixImage] Prompt-guided image variation operations.
|
|
22
|
+
attr_reader :remix_image
|
|
23
|
+
# @return [Resources::ReframeImage] Aspect ratio reframing operations.
|
|
24
|
+
attr_reader :reframe_image
|
|
19
25
|
|
|
20
26
|
def initialize(api_key: nil, **options)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
client_options = Core::ClientOptions.new(api_key: @api_key, **options)
|
|
24
|
-
http = client_options.http_client || Core::HttpClient.new(client_options)
|
|
27
|
+
super
|
|
25
28
|
@text_to_image = Resources::TextToImage.new(http)
|
|
26
29
|
@edit_image = Resources::EditImage.new(http)
|
|
27
30
|
@remix_image = Resources::RemixImage.new(http)
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module IdeogramV3
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"edit-image" => {
|
|
7
|
+
"models" => ["ideogram-v3-character-edit", "ideogram-v3-edit"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"ideogram-v3-character-edit" => {
|
|
10
|
+
"mask_url" => {
|
|
11
|
+
"required" => true
|
|
12
|
+
},
|
|
13
|
+
"output_count" => {
|
|
14
|
+
"enum" => [1, 2, 3, 4],
|
|
15
|
+
"type" => "integer"
|
|
16
|
+
},
|
|
17
|
+
"reference_image_urls" => {
|
|
18
|
+
"required" => true
|
|
19
|
+
},
|
|
20
|
+
"rendering_speed" => {
|
|
21
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
22
|
+
},
|
|
23
|
+
"seed" => {
|
|
24
|
+
"type" => "integer"
|
|
25
|
+
},
|
|
26
|
+
"source_image_url" => {
|
|
27
|
+
"required" => true
|
|
28
|
+
},
|
|
29
|
+
"style" => {
|
|
30
|
+
"enum" => ["auto", "realistic", "fiction"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"ideogram-v3-edit" => {
|
|
34
|
+
"mask_url" => {
|
|
35
|
+
"required" => true
|
|
36
|
+
},
|
|
37
|
+
"output_count" => {
|
|
38
|
+
"enum" => [1, 2, 3, 4],
|
|
39
|
+
"type" => "integer"
|
|
40
|
+
},
|
|
41
|
+
"rendering_speed" => {
|
|
42
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
43
|
+
},
|
|
44
|
+
"seed" => {
|
|
45
|
+
"type" => "integer"
|
|
46
|
+
},
|
|
47
|
+
"source_image_url" => {
|
|
48
|
+
"required" => true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"reframe-image" => {
|
|
54
|
+
"models" => ["ideogram-v3-reframe"],
|
|
55
|
+
"fields_by_model" => {
|
|
56
|
+
"ideogram-v3-reframe" => {
|
|
57
|
+
"aspect_ratio" => {
|
|
58
|
+
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
59
|
+
},
|
|
60
|
+
"output_count" => {
|
|
61
|
+
"enum" => [1, 2, 3, 4],
|
|
62
|
+
"type" => "integer"
|
|
63
|
+
},
|
|
64
|
+
"rendering_speed" => {
|
|
65
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
66
|
+
},
|
|
67
|
+
"seed" => {
|
|
68
|
+
"type" => "integer"
|
|
69
|
+
},
|
|
70
|
+
"source_image_url" => {
|
|
71
|
+
"required" => true
|
|
72
|
+
},
|
|
73
|
+
"style" => {
|
|
74
|
+
"enum" => ["auto", "general", "realistic", "design"]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"remix-image" => {
|
|
80
|
+
"models" => ["ideogram-v3-character-remix", "ideogram-v3-remix"],
|
|
81
|
+
"fields_by_model" => {
|
|
82
|
+
"ideogram-v3-character-remix" => {
|
|
83
|
+
"aspect_ratio" => {
|
|
84
|
+
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
85
|
+
},
|
|
86
|
+
"output_count" => {
|
|
87
|
+
"enum" => [1, 2, 3, 4],
|
|
88
|
+
"type" => "integer"
|
|
89
|
+
},
|
|
90
|
+
"reference_image_urls" => {
|
|
91
|
+
"required" => true
|
|
92
|
+
},
|
|
93
|
+
"rendering_speed" => {
|
|
94
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
95
|
+
},
|
|
96
|
+
"seed" => {
|
|
97
|
+
"type" => "integer"
|
|
98
|
+
},
|
|
99
|
+
"source_image_url" => {
|
|
100
|
+
"required" => true
|
|
101
|
+
},
|
|
102
|
+
"style" => {
|
|
103
|
+
"enum" => ["auto", "realistic", "fiction"]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"ideogram-v3-remix" => {
|
|
107
|
+
"aspect_ratio" => {
|
|
108
|
+
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
109
|
+
},
|
|
110
|
+
"output_count" => {
|
|
111
|
+
"enum" => [1, 2, 3, 4],
|
|
112
|
+
"type" => "integer"
|
|
113
|
+
},
|
|
114
|
+
"rendering_speed" => {
|
|
115
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
116
|
+
},
|
|
117
|
+
"seed" => {
|
|
118
|
+
"type" => "integer"
|
|
119
|
+
},
|
|
120
|
+
"source_image_url" => {
|
|
121
|
+
"required" => true
|
|
122
|
+
},
|
|
123
|
+
"style" => {
|
|
124
|
+
"enum" => ["auto", "general", "realistic", "design"]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"text-to-image" => {
|
|
130
|
+
"models" => ["ideogram-v3-character", "ideogram-v3-text-to-image"],
|
|
131
|
+
"fields_by_model" => {
|
|
132
|
+
"ideogram-v3-character" => {
|
|
133
|
+
"aspect_ratio" => {
|
|
134
|
+
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
135
|
+
},
|
|
136
|
+
"output_count" => {
|
|
137
|
+
"enum" => [1, 2, 3, 4],
|
|
138
|
+
"type" => "integer"
|
|
139
|
+
},
|
|
140
|
+
"reference_image_urls" => {
|
|
141
|
+
"required" => true
|
|
142
|
+
},
|
|
143
|
+
"rendering_speed" => {
|
|
144
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
145
|
+
},
|
|
146
|
+
"seed" => {
|
|
147
|
+
"type" => "integer"
|
|
148
|
+
},
|
|
149
|
+
"style" => {
|
|
150
|
+
"enum" => ["auto", "realistic", "fiction"]
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"ideogram-v3-text-to-image" => {
|
|
154
|
+
"aspect_ratio" => {
|
|
155
|
+
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
156
|
+
},
|
|
157
|
+
"output_count" => {
|
|
158
|
+
"enum" => [1, 2, 3, 4],
|
|
159
|
+
"type" => "integer"
|
|
160
|
+
},
|
|
161
|
+
"rendering_speed" => {
|
|
162
|
+
"enum" => ["turbo", "balanced", "quality"]
|
|
163
|
+
},
|
|
164
|
+
"seed" => {
|
|
165
|
+
"type" => "integer"
|
|
166
|
+
},
|
|
167
|
+
"style" => {
|
|
168
|
+
"enum" => ["auto", "general", "realistic", "design"]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}.freeze
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module IdeogramV3
|
|
5
5
|
module Resources
|
|
6
|
-
# Inpaint
|
|
6
|
+
# Inpaint editing using a mask to define the regenerated region.
|
|
7
7
|
class EditImage
|
|
8
8
|
include RunApi::Core::ResourceHelpers
|
|
9
9
|
|
|
@@ -16,29 +16,26 @@ module RunApi
|
|
|
16
16
|
@http = http
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def run(**params)
|
|
20
|
-
task = create(**params)
|
|
21
|
-
poll_until_complete { get(task.id) }
|
|
19
|
+
def run(options: nil, **params)
|
|
20
|
+
task = create(options: options, **params)
|
|
21
|
+
poll_until_complete { get(task.id, options: options) }
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def create(**params)
|
|
24
|
+
def create(options: nil, **params)
|
|
25
25
|
params = compact_params(params)
|
|
26
26
|
validate_params!(params)
|
|
27
|
-
request(:post, ENDPOINT, body: params)
|
|
27
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def get(id)
|
|
31
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
|
+
def get(id, options: nil)
|
|
31
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def validate_params!(params)
|
|
37
|
+
validate_contract!(CONTRACT["edit-image"], params)
|
|
37
38
|
model = param(params, :model)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless model
|
|
39
|
-
unless [Types::EDIT_MODEL, Types::CHARACTER_EDIT_MODEL].include?(model)
|
|
40
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be #{Types::EDIT_MODEL} or #{Types::CHARACTER_EDIT_MODEL}"
|
|
41
|
-
end
|
|
42
39
|
|
|
43
40
|
prompt = param(params, :prompt)
|
|
44
41
|
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
@@ -46,10 +43,8 @@ module RunApi
|
|
|
46
43
|
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
50
46
|
raise Core::ValidationError, "mask_url is required" unless param(params, :mask_url)
|
|
51
47
|
|
|
52
|
-
validate_optional!(params, :rendering_speed, Types::RENDERING_SPEEDS)
|
|
53
48
|
validate_character_fields!(params, model)
|
|
54
49
|
end
|
|
55
50
|
|
|
@@ -57,18 +52,9 @@ module RunApi
|
|
|
57
52
|
refs = param(params, :reference_image_urls)
|
|
58
53
|
if model == Types::CHARACTER_EDIT_MODEL
|
|
59
54
|
raise Core::ValidationError, "reference_image_urls is required" unless refs.is_a?(Array) && refs.any?
|
|
60
|
-
validate_optional!(params, :style, Types::CHARACTER_STYLES)
|
|
61
55
|
elsif refs || param(params, :style)
|
|
62
56
|
raise Core::ValidationError, "character edit fields are not supported for #{model}"
|
|
63
57
|
end
|
|
64
|
-
validate_output_count!(params)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def validate_output_count!(params)
|
|
68
|
-
return unless (output_count = param(params, :output_count))
|
|
69
|
-
return if Types::OUTPUT_COUNTS.include?(output_count)
|
|
70
|
-
|
|
71
|
-
raise Core::ValidationError, "Invalid output_count: #{output_count}. Must be one of: #{Types::OUTPUT_COUNTS.join(", ")}"
|
|
72
58
|
end
|
|
73
59
|
end
|
|
74
60
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module IdeogramV3
|
|
5
5
|
module Resources
|
|
6
|
-
#
|
|
6
|
+
# Extends or crops an image to a new aspect ratio without regenerating content.
|
|
7
7
|
class ReframeImage
|
|
8
8
|
include RunApi::Core::ResourceHelpers
|
|
9
9
|
|
|
@@ -15,44 +15,27 @@ module RunApi
|
|
|
15
15
|
@http = http
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def run(**params)
|
|
19
|
-
task = create(**params)
|
|
20
|
-
poll_until_complete { get(task.id) }
|
|
18
|
+
def run(options: nil, **params)
|
|
19
|
+
task = create(options: options, **params)
|
|
20
|
+
poll_until_complete { get(task.id, options: options) }
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def create(**params)
|
|
23
|
+
def create(options: nil, **params)
|
|
24
24
|
params = compact_params(params)
|
|
25
25
|
validate_params!(params)
|
|
26
|
-
request(:post, ENDPOINT, body: params)
|
|
26
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def get(id)
|
|
30
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
29
|
+
def get(id, options: nil)
|
|
30
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
35
|
def validate_params!(params)
|
|
36
|
-
|
|
37
|
-
raise Core::ValidationError, "model is required" unless model
|
|
38
|
-
unless model == Types::REFRAME_MODEL
|
|
39
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be #{Types::REFRAME_MODEL}"
|
|
40
|
-
end
|
|
36
|
+
validate_contract!(CONTRACT["reframe-image"], params)
|
|
41
37
|
|
|
42
|
-
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
43
38
|
raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
|
|
44
|
-
|
|
45
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
46
|
-
validate_optional!(params, :rendering_speed, Types::RENDERING_SPEEDS)
|
|
47
|
-
validate_optional!(params, :style, Types::STYLES)
|
|
48
|
-
validate_output_count!(params)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def validate_output_count!(params)
|
|
52
|
-
return unless (output_count = param(params, :output_count))
|
|
53
|
-
return if Types::OUTPUT_COUNTS.include?(output_count)
|
|
54
|
-
|
|
55
|
-
raise Core::ValidationError, "Invalid output_count: #{output_count}. Must be one of: #{Types::OUTPUT_COUNTS.join(", ")}"
|
|
56
39
|
end
|
|
57
40
|
end
|
|
58
41
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module IdeogramV3
|
|
5
5
|
module Resources
|
|
6
|
-
#
|
|
6
|
+
# Creates a variation of a source image guided by a new text prompt.
|
|
7
7
|
class RemixImage
|
|
8
8
|
include RunApi::Core::ResourceHelpers
|
|
9
9
|
|
|
@@ -19,29 +19,26 @@ module RunApi
|
|
|
19
19
|
@http = http
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def run(**params)
|
|
23
|
-
task = create(**params)
|
|
24
|
-
poll_until_complete { get(task.id) }
|
|
22
|
+
def run(options: nil, **params)
|
|
23
|
+
task = create(options: options, **params)
|
|
24
|
+
poll_until_complete { get(task.id, options: options) }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def create(**params)
|
|
27
|
+
def create(options: nil, **params)
|
|
28
28
|
params = compact_params(params)
|
|
29
29
|
validate_params!(params)
|
|
30
|
-
request(:post, ENDPOINT, body: params)
|
|
30
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def get(id)
|
|
34
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
33
|
+
def get(id, options: nil)
|
|
34
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
private
|
|
38
38
|
|
|
39
39
|
def validate_params!(params)
|
|
40
|
+
validate_contract!(CONTRACT["remix-image"], params)
|
|
40
41
|
model = param(params, :model)
|
|
41
|
-
raise Core::ValidationError, "model is required" unless model
|
|
42
|
-
unless [Types::REMIX_MODEL, Types::CHARACTER_REMIX_MODEL].include?(model)
|
|
43
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be #{Types::REMIX_MODEL} or #{Types::CHARACTER_REMIX_MODEL}"
|
|
44
|
-
end
|
|
45
42
|
|
|
46
43
|
prompt = param(params, :prompt)
|
|
47
44
|
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
@@ -49,20 +46,8 @@ module RunApi
|
|
|
49
46
|
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
50
47
|
end
|
|
51
48
|
|
|
52
|
-
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
53
|
-
|
|
54
|
-
validate_optional!(params, :rendering_speed, Types::RENDERING_SPEEDS)
|
|
55
|
-
style_values = (model == Types::CHARACTER_REMIX_MODEL) ? Types::CHARACTER_STYLES : Types::STYLES
|
|
56
|
-
validate_optional!(params, :style, style_values)
|
|
57
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
58
49
|
validate_character_fields!(params, model)
|
|
59
50
|
|
|
60
|
-
if (output_count = param(params, :output_count))
|
|
61
|
-
unless Types::OUTPUT_COUNTS.include?(output_count)
|
|
62
|
-
raise Core::ValidationError, "Invalid output_count: #{output_count}. Must be one of: #{Types::OUTPUT_COUNTS.join(", ")}"
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
51
|
if (strength = param(params, :strength))
|
|
67
52
|
numeric = Float(strength, exception: false)
|
|
68
53
|
min = (model == Types::CHARACTER_REMIX_MODEL) ? CHARACTER_REMIX_STRENGTH_MIN : STRENGTH_MIN
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module IdeogramV3
|
|
5
5
|
module Resources
|
|
6
|
-
#
|
|
6
|
+
# Generates images from text with configurable speed, style, and aspect ratio.
|
|
7
7
|
class TextToImage
|
|
8
8
|
include RunApi::Core::ResourceHelpers
|
|
9
9
|
|
|
@@ -16,29 +16,26 @@ module RunApi
|
|
|
16
16
|
@http = http
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def run(**params)
|
|
20
|
-
task = create(**params)
|
|
21
|
-
poll_until_complete { get(task.id) }
|
|
19
|
+
def run(options: nil, **params)
|
|
20
|
+
task = create(options: options, **params)
|
|
21
|
+
poll_until_complete { get(task.id, options: options) }
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def create(**params)
|
|
24
|
+
def create(options: nil, **params)
|
|
25
25
|
params = compact_params(params)
|
|
26
26
|
validate_params!(params)
|
|
27
|
-
request(:post, ENDPOINT, body: params)
|
|
27
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def get(id)
|
|
31
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
|
+
def get(id, options: nil)
|
|
31
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def validate_params!(params)
|
|
37
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
37
38
|
model = param(params, :model)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless model
|
|
39
|
-
unless [Types::GENERATION_MODEL, Types::CHARACTER_MODEL].include?(model)
|
|
40
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be #{Types::GENERATION_MODEL} or #{Types::CHARACTER_MODEL}"
|
|
41
|
-
end
|
|
42
39
|
|
|
43
40
|
prompt = param(params, :prompt)
|
|
44
41
|
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
@@ -46,12 +43,7 @@ module RunApi
|
|
|
46
43
|
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
validate_optional!(params, :rendering_speed, Types::RENDERING_SPEEDS)
|
|
50
|
-
style_values = (model == Types::CHARACTER_MODEL) ? Types::CHARACTER_STYLES : Types::STYLES
|
|
51
|
-
validate_optional!(params, :style, style_values)
|
|
52
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
53
46
|
validate_character_refs!(params, model)
|
|
54
|
-
validate_output_count!(params)
|
|
55
47
|
end
|
|
56
48
|
|
|
57
49
|
def validate_character_refs!(params, model)
|
|
@@ -62,14 +54,6 @@ module RunApi
|
|
|
62
54
|
raise Core::ValidationError, "reference_image_urls is not supported for #{model}"
|
|
63
55
|
end
|
|
64
56
|
end
|
|
65
|
-
|
|
66
|
-
def validate_output_count!(params)
|
|
67
|
-
output_count = param(params, :output_count)
|
|
68
|
-
return unless output_count
|
|
69
|
-
return if Types::OUTPUT_COUNTS.include?(output_count)
|
|
70
|
-
|
|
71
|
-
raise Core::ValidationError, "Invalid output_count: #{output_count}. Must be one of: #{Types::OUTPUT_COUNTS.join(", ")}"
|
|
72
|
-
end
|
|
73
57
|
end
|
|
74
58
|
end
|
|
75
59
|
end
|
|
@@ -2,25 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module IdeogramV3
|
|
5
|
+
# Type definitions and constants for Ideogram V3.
|
|
6
|
+
# Character model variants add character consistency from reference images.
|
|
5
7
|
module Types
|
|
6
|
-
GENERATION_MODEL = "ideogram-v3-text-to-image"
|
|
7
|
-
EDIT_MODEL = "ideogram-v3-edit"
|
|
8
|
-
REMIX_MODEL = "ideogram-v3-remix"
|
|
9
8
|
CHARACTER_MODEL = "ideogram-v3-character"
|
|
10
9
|
CHARACTER_EDIT_MODEL = "ideogram-v3-character-edit"
|
|
11
10
|
CHARACTER_REMIX_MODEL = "ideogram-v3-character-remix"
|
|
12
|
-
REFRAME_MODEL = "ideogram-v3-reframe"
|
|
13
|
-
|
|
14
|
-
RENDERING_SPEEDS = %w[turbo balanced quality].freeze
|
|
15
|
-
STYLES = %w[auto general realistic design].freeze
|
|
16
|
-
CHARACTER_STYLES = %w[auto realistic fiction].freeze
|
|
17
|
-
ASPECT_RATIOS = %w[1:1 3:4 9:16 4:3 16:9].freeze
|
|
18
|
-
OUTPUT_COUNTS = [1, 2, 3, 4].freeze
|
|
19
11
|
|
|
12
|
+
# A single generated image with its CDN URL.
|
|
20
13
|
class Image < RunApi::Core::BaseModel
|
|
21
14
|
optional :url, String
|
|
22
15
|
end
|
|
23
16
|
|
|
17
|
+
# Normalized response for all Ideogram V3 endpoints.
|
|
18
|
+
# +images+ is populated once +status+ is +"completed"+.
|
|
24
19
|
class IdeogramResponse < RunApi::Core::TaskResponse
|
|
25
20
|
required :id, String
|
|
26
21
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
data/lib/runapi/ideogram_v3.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "runapi/core"
|
|
4
4
|
require_relative "ideogram_v3/types"
|
|
5
|
+
require_relative "ideogram_v3/contract_gen"
|
|
5
6
|
require_relative "ideogram_v3/resources/text_to_image"
|
|
6
7
|
require_relative "ideogram_v3/resources/edit_image"
|
|
7
8
|
require_relative "ideogram_v3/resources/remix_image"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-ideogram-v3
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.8
|
|
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.
|
|
18
|
+
version: 0.3.0
|
|
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.
|
|
26
|
-
description: The
|
|
27
|
-
V3 on RunAPI. Use this
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
version: 0.3.0
|
|
26
|
+
description: The Ideogram V3 Ruby SDK is the language-specific package for Ideogram
|
|
27
|
+
V3 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-ideogram_v3.rb
|
|
40
40
|
- lib/runapi/ideogram_v3.rb
|
|
41
41
|
- lib/runapi/ideogram_v3/client.rb
|
|
42
|
+
- lib/runapi/ideogram_v3/contract_gen.rb
|
|
42
43
|
- lib/runapi/ideogram_v3/resources/edit_image.rb
|
|
43
44
|
- lib/runapi/ideogram_v3/resources/reframe_image.rb
|
|
44
45
|
- lib/runapi/ideogram_v3/resources/remix_image.rb
|
|
@@ -48,9 +49,11 @@ homepage: https://runapi.ai/models/ideogram-v3
|
|
|
48
49
|
licenses:
|
|
49
50
|
- Apache-2.0
|
|
50
51
|
metadata:
|
|
52
|
+
runapi_slug: ideogram-v3
|
|
51
53
|
homepage_uri: https://runapi.ai/models/ideogram-v3
|
|
52
54
|
documentation_uri: https://github.com/runapi-ai/ideogram-v3-sdk/blob/main/ruby/README.md
|
|
53
55
|
source_code_uri: https://github.com/runapi-ai/ideogram-v3-sdk
|
|
56
|
+
bug_tracker_uri: https://github.com/runapi-ai/ideogram-v3-sdk/issues
|
|
54
57
|
changelog_uri: https://github.com/runapi-ai/ideogram-v3-sdk/blob/main/CHANGELOG.md
|
|
55
58
|
rdoc_options: []
|
|
56
59
|
require_paths:
|
|
@@ -66,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
69
|
- !ruby/object:Gem::Version
|
|
67
70
|
version: '0'
|
|
68
71
|
requirements: []
|
|
69
|
-
rubygems_version: 4.0.
|
|
72
|
+
rubygems_version: 4.0.17
|
|
70
73
|
specification_version: 4
|
|
71
|
-
summary: Ideogram API Ruby SDK for RunAPI
|
|
74
|
+
summary: Ideogram V3 API Ruby SDK for RunAPI
|
|
72
75
|
test_files: []
|