runapi-flux-kontext 0.2.6 → 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: a7a15941bf71d6217337b7d0dfa6b1136a57f2f9763c24b3a1d4aed5533d8278
4
- data.tar.gz: 0b126bee144555fba38ffe81675fdbef5933c3eb21017e54c70e86cf75a2c96f
3
+ metadata.gz: 375bd55954b0fcc6fc0af7cb22d3102a67e40b216aebb3f7036f88235854a1cf
4
+ data.tar.gz: bb1146e64a121ed83e2315925dcdccf108d9937f08cafdff698bed0ba1d03bbc
5
5
  SHA512:
6
- metadata.gz: 43a7d9be562a0877a517d0a36fe7c485f82e6ea543443787fc158721de1e968661108d0f6875a61da7e115856987384f1c9bb254f7ee239ac10b4458d5ca515c
7
- data.tar.gz: 9c441b767fb721514c06266d43a3198599c27ac597b79c7cac0c8b0e630766844221a0b9f00d99d8363c5e1e38eca88ebc3d37f8272f9a74c90453ab0fa51723
6
+ metadata.gz: c1ba0956ecaac80618fefbb20fa3838b2db99e7ad74905b70922e0376fab40beb1f60cb74132570411bb5f13900d9069dd9ab7ba8d07cf58e615bae407d5cd4b
7
+ data.tar.gz: eb9fac4245227b237775a761c98d4b9c76338e8f05a53682a704eef9d3019fe6ae0194e417c97b4c5f3345d77fb1f944fbec1e2efbe320271260be59ce65334d
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Flux Kontext API Ruby SDK for RunAPI
1
+ # Flux Kontext Ruby SDK for RunAPI
2
2
 
3
- The flux kontext api Ruby SDK is the language-specific package for Flux Kontext on RunAPI. Use this flux kontext 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.
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 flux kontext api 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.
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,10 +16,10 @@ gem install runapi-flux-kontext
16
16
  require "runapi-flux-kontext"
17
17
 
18
18
  client = RunApi::FluxKontext::Client.new
19
- task = client.generations.create(
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.generations.get(task.id)
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.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
31
- Use Ruby keyword arguments and the `RunApi::FluxKontext` error classes when building image jobs, Rails workers, or scripts. The available resources include generations. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
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.
32
32
 
33
33
  ## Links
34
34
 
@@ -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
- validate_params!(params)
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
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "flux_kontext/types"
5
+ require_relative "flux_kontext/contract_gen"
5
6
  require_relative "flux_kontext/resources/text_to_image"
6
7
  require_relative "flux_kontext/client"
7
8
 
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.6
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.6
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.6
26
- description: The flux kontext api Ruby SDK is the language-specific package for Flux
27
- Kontext on RunAPI. Use this flux kontext 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.
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 API Ruby SDK for RunAPI
71
+ summary: Flux Kontext Ruby SDK for RunAPI
69
72
  test_files: []