runapi-flux-kontext 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7a15941bf71d6217337b7d0dfa6b1136a57f2f9763c24b3a1d4aed5533d8278
4
- data.tar.gz: 0b126bee144555fba38ffe81675fdbef5933c3eb21017e54c70e86cf75a2c96f
3
+ metadata.gz: 57ca847ab8beff9fed385c42627d4cd19e78861ace2358203947dce22b607e18
4
+ data.tar.gz: e36181fc9c66c936e0bfa9a208bbd8c443ca8287d972df51b912cd254564a5b1
5
5
  SHA512:
6
- metadata.gz: 43a7d9be562a0877a517d0a36fe7c485f82e6ea543443787fc158721de1e968661108d0f6875a61da7e115856987384f1c9bb254f7ee239ac10b4458d5ca515c
7
- data.tar.gz: 9c441b767fb721514c06266d43a3198599c27ac597b79c7cac0c8b0e630766844221a0b9f00d99d8363c5e1e38eca88ebc3d37f8272f9a74c90453ab0fa51723
6
+ metadata.gz: 0441a5627c3f9d02e09a7bafb89ba0b091b2f516328980ee813e338a36b9f2758dc53401ba8f90b6dcab6ca30f156d3fc667e0d5941362b034f36dacf649f73f
7
+ data.tar.gz: 6b32f79fcc8ef6cd0639d95a26d4737f95ae9e959b72bc7db553b35f56a76dcab073a6c110f09eb3d6948e74a8c738a7e682c827227f969f64871d0d301f6b60
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
 
@@ -13,13 +13,13 @@ gem install runapi-flux-kontext
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-flux-kontext"
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
@@ -21,42 +21,27 @@ module RunApi
21
21
  #
22
22
  # @param params [Hash] generation parameters
23
23
  # @return [RunApi::FluxKontext::Types::CompletedTextToImageResponse] completed generation with images
24
- def run(**params)
25
- task = create(**params)
26
- poll_until_complete { get(task.id) }
24
+ def run(options: nil, **params)
25
+ task = create(options: options, **params)
26
+ poll_until_complete { get(task.id, options: options) }
27
27
  end
28
28
 
29
29
  # Create an image generation task.
30
30
  #
31
31
  # @param params [Hash] generation parameters
32
32
  # @return [RunApi::FluxKontext::Types::TextToImageResponse] task creation result with id
33
- def create(**params)
33
+ def create(options: nil, **params)
34
34
  params = compact_params(params)
35
- validate_params!(params)
36
- request(:post, ENDPOINT, body: params)
35
+ validate_contract!(CONTRACT["text-to-image"], params)
36
+ request(:post, ENDPOINT, body: params, options: options)
37
37
  end
38
38
 
39
39
  # Get generation status by task ID.
40
40
  #
41
41
  # @param id [String] task ID
42
42
  # @return [RunApi::FluxKontext::Types::TextToImageResponse] current generation status
43
- def get(id)
44
- request(:get, "#{ENDPOINT}/#{id}")
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)
43
+ def get(id, options: nil)
44
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
60
45
  end
61
46
  end
62
47
  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.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.2.6
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.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.3.0
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:
@@ -63,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
66
  - !ruby/object:Gem::Version
64
67
  version: '0'
65
68
  requirements: []
66
- rubygems_version: 4.0.10
69
+ rubygems_version: 4.0.17
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: []