runapi-flux-kontext 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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 375bd55954b0fcc6fc0af7cb22d3102a67e40b216aebb3f7036f88235854a1cf
|
|
4
|
+
data.tar.gz: bb1146e64a121ed83e2315925dcdccf108d9937f08cafdff698bed0ba1d03bbc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1ba0956ecaac80618fefbb20fa3838b2db99e7ad74905b70922e0376fab40beb1f60cb74132570411bb5f13900d9069dd9ab7ba8d07cf58e615bae407d5cd4b
|
|
7
|
+
data.tar.gz: eb9fac4245227b237775a761c98d4b9c76338e8f05a53682a704eef9d3019fe6ae0194e417c97b4c5f3345d77fb1f944fbec1e2efbe320271260be59ce65334d
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Flux Kontext
|
|
1
|
+
# Flux Kontext Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Flux Kontext Ruby SDK is the language-specific package for Flux Kontext 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 `flux-kontext-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/flux-kontext; for API reference, use https://runapi.ai/docs#flux-kontext; for SDK docs, use https://runapi.ai/docs#sdk-flux-kontext.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,17 +16,19 @@ gem install runapi-flux-kontext
|
|
|
16
16
|
require "runapi-flux-kontext"
|
|
17
17
|
|
|
18
18
|
client = RunApi::FluxKontext::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.text_to_image.create(
|
|
20
20
|
# Pass the Flux Kontext JSON request body from https://runapi.ai/docs#flux-kontext.
|
|
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::FluxKontext` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::FluxKontext` 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,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module FluxKontext
|
|
5
|
-
# Flux Kontext image generation API client.
|
|
5
|
+
# Flux Kontext image generation and editing API client.
|
|
6
|
+
#
|
|
7
|
+
# Supports pure text-to-image generation and image editing via
|
|
8
|
+
# source_image_url. Pro and max quality tiers available.
|
|
6
9
|
#
|
|
7
10
|
# @example
|
|
8
11
|
# client = RunApi::FluxKontext::Client.new(api_key: "your-api-key")
|
|
9
12
|
# result = client.text_to_image.run(
|
|
10
13
|
# model: "flux-kontext-pro", prompt: "A futuristic cityscape"
|
|
11
14
|
# )
|
|
12
|
-
class Client
|
|
15
|
+
class Client < RunApi::Core::Client
|
|
13
16
|
# @return [Resources::TextToImage] Image generation operations.
|
|
14
17
|
attr_reader :text_to_image
|
|
15
18
|
|
|
16
19
|
def initialize(api_key: nil, **options)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
client_options = Core::ClientOptions.new(api_key: @api_key, **options)
|
|
20
|
-
http = client_options.http_client || Core::HttpClient.new(client_options)
|
|
20
|
+
super
|
|
21
21
|
@text_to_image = Resources::TextToImage.new(http)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module FluxKontext
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"text-to-image" => {
|
|
7
|
+
"models" => ["flux-kontext-max", "flux-kontext-pro"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"flux-kontext-max" => {
|
|
10
|
+
"aspect_ratio" => {
|
|
11
|
+
"enum" => ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"]
|
|
12
|
+
},
|
|
13
|
+
"model" => {
|
|
14
|
+
"required" => true
|
|
15
|
+
},
|
|
16
|
+
"output_format" => {
|
|
17
|
+
"enum" => ["jpeg", "png"]
|
|
18
|
+
},
|
|
19
|
+
"prompt" => {
|
|
20
|
+
"required" => true
|
|
21
|
+
},
|
|
22
|
+
"safety_tolerance" => {
|
|
23
|
+
"type" => "integer"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"flux-kontext-pro" => {
|
|
27
|
+
"aspect_ratio" => {
|
|
28
|
+
"enum" => ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"]
|
|
29
|
+
},
|
|
30
|
+
"model" => {
|
|
31
|
+
"required" => true
|
|
32
|
+
},
|
|
33
|
+
"output_format" => {
|
|
34
|
+
"enum" => ["jpeg", "png"]
|
|
35
|
+
},
|
|
36
|
+
"prompt" => {
|
|
37
|
+
"required" => true
|
|
38
|
+
},
|
|
39
|
+
"safety_tolerance" => {
|
|
40
|
+
"type" => "integer"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}.freeze
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -32,7 +32,7 @@ module RunApi
|
|
|
32
32
|
# @return [RunApi::FluxKontext::Types::TextToImageResponse] task creation result with id
|
|
33
33
|
def create(**params)
|
|
34
34
|
params = compact_params(params)
|
|
35
|
-
|
|
35
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
36
36
|
request(:post, ENDPOINT, body: params)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -43,21 +43,6 @@ module RunApi
|
|
|
43
43
|
def get(id)
|
|
44
44
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
45
45
|
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def validate_params!(params)
|
|
50
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
51
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
52
|
-
|
|
53
|
-
model = param(params, :model)
|
|
54
|
-
unless Types::MODELS.include?(model)
|
|
55
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::MODELS.join(", ")}"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
59
|
-
validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
|
|
60
|
-
end
|
|
61
46
|
end
|
|
62
47
|
end
|
|
63
48
|
end
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module FluxKontext
|
|
5
5
|
module Types
|
|
6
|
-
MODELS = %w[flux-kontext-pro flux-kontext-max].freeze
|
|
7
|
-
|
|
8
|
-
ASPECT_RATIOS = %w[21:9 16:9 4:3 1:1 3:4 9:16].freeze
|
|
9
|
-
OUTPUT_FORMATS = %w[jpeg png].freeze
|
|
10
|
-
|
|
11
6
|
class Image < RunApi::Core::BaseModel
|
|
12
7
|
optional :url, String
|
|
13
8
|
optional :origin_url, String
|
data/lib/runapi/flux_kontext.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-flux-kontext
|
|
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 Flux Kontext Ruby SDK is the language-specific package for Flux Kontext
|
|
27
|
+
on RunAPI. Use this package for image generation, image editing, and creative production
|
|
28
|
+
workflows when your application needs request bodies, task status lookup, and consistent
|
|
29
|
+
RunAPI errors in Ruby.
|
|
30
30
|
email:
|
|
31
31
|
- contact@runapi.ai
|
|
32
32
|
executables: []
|
|
@@ -39,15 +39,18 @@ files:
|
|
|
39
39
|
- lib/runapi-flux_kontext.rb
|
|
40
40
|
- lib/runapi/flux_kontext.rb
|
|
41
41
|
- lib/runapi/flux_kontext/client.rb
|
|
42
|
+
- lib/runapi/flux_kontext/contract_gen.rb
|
|
42
43
|
- lib/runapi/flux_kontext/resources/text_to_image.rb
|
|
43
44
|
- lib/runapi/flux_kontext/types.rb
|
|
44
45
|
homepage: https://runapi.ai/models/flux-kontext
|
|
45
46
|
licenses:
|
|
46
47
|
- Apache-2.0
|
|
47
48
|
metadata:
|
|
49
|
+
runapi_slug: flux-kontext
|
|
48
50
|
homepage_uri: https://runapi.ai/models/flux-kontext
|
|
49
51
|
documentation_uri: https://github.com/runapi-ai/flux-kontext-sdk/blob/main/ruby/README.md
|
|
50
52
|
source_code_uri: https://github.com/runapi-ai/flux-kontext-sdk
|
|
53
|
+
bug_tracker_uri: https://github.com/runapi-ai/flux-kontext-sdk/issues
|
|
51
54
|
changelog_uri: https://github.com/runapi-ai/flux-kontext-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: Flux Kontext
|
|
71
|
+
summary: Flux Kontext Ruby SDK for RunAPI
|
|
69
72
|
test_files: []
|