runapi-qwen-2 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: f7cbfba501dd88b37a82629dee1237753f030d6d92a06faac41f6165985aed21
4
- data.tar.gz: ec3086cde57f139b0621c21c4e33e18a32aefbaf96be7f53c9757ddefb2631a4
3
+ metadata.gz: 1f3700e2cf81d87fa6bf94631a0f6d153cbc481a5b978f1f6a684f2986a8ebda
4
+ data.tar.gz: 948da5705c89ac0e4cab9b06c6a89e36426615d9b1e8656095a04e0ee2450dbc
5
5
  SHA512:
6
- metadata.gz: c98213aac1b753e131550119533febb83cbf2e7543479750074458085e54d5be05772018d511f0cb3011aa70c55bbe1d53bce4691b410cfdea7758ade3c4f840
7
- data.tar.gz: 7f564584fcde1efed7db34abf0a606d36ca59661b496f449cdf00d8137d9a91c32765e5289e357ed15a58627424dbf0ff91ee1a3335c5c6963045ae388550be8
6
+ metadata.gz: d23d2d3fd38f3a16f49214ad0f122dbed63504eb61eaa463e41fa584a4a93efe7e61d2027997d996b8fb2d51d04edcbea50e12964e8b3a5c5f584f6cf86ecdcc
7
+ data.tar.gz: 981e76b782d1584f10e782be8d45e38a3a267d7f0adc8d47f799f01eaf0a16a3809278b42ffead6a04ae356aee77b114d8acc5a1bb2f91f5dafdce23f695fb89
data/README.md CHANGED
@@ -24,6 +24,8 @@ status = client.generations.get(task.id)
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
31
  Use Ruby keyword arguments and the `RunApi::Qwen2` error classes when building image jobs, Rails workers, or scripts. The available resources include generations, image to images, and edits. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
@@ -2,7 +2,11 @@
2
2
 
3
3
  module RunApi
4
4
  module Qwen2
5
- # Qwen2 text-to-image, remix-image, and edit-image API client.
5
+ # Qwen 2 image generation, remixing, and editing API client.
6
+ #
7
+ # Three operations: pure text-to-image generation, remix (prompt-guided
8
+ # variation of a source image with configurable strength), and edit
9
+ # (targeted modifications to a source image).
6
10
  #
7
11
  # @example
8
12
  # client = RunApi::Qwen2::Client.new(api_key: "your-api-key")
@@ -11,15 +15,16 @@ module RunApi
11
15
  # prompt: "Replace the background with a neon-lit city skyline",
12
16
  # source_image_url: "https://cdn.runapi.ai/public/samples/input.jpg"
13
17
  # )
14
- class Client
15
- # @return [Resources::TextToImage, Resources::RemixImage, Resources::EditImage] Image operations.
16
- attr_reader :text_to_image, :remix_image, :edit_image
18
+ class Client < RunApi::Core::Client
19
+ # @return [Resources::TextToImage] Generate images from text prompts.
20
+ attr_reader :text_to_image
21
+ # @return [Resources::RemixImage] Create prompt-guided variations with adjustable strength (0 = faithful, 1 = creative).
22
+ attr_reader :remix_image
23
+ # @return [Resources::EditImage] Apply targeted edits to a source image using natural-language prompts.
24
+ attr_reader :edit_image
17
25
 
18
26
  def initialize(api_key: nil, **options)
19
- @api_key = Core::Auth.resolve_api_key(api_key)
20
-
21
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
22
- http = client_options.http_client || Core::HttpClient.new(client_options)
27
+ super
23
28
  @text_to_image = Resources::TextToImage.new(http)
24
29
  @remix_image = Resources::RemixImage.new(http)
25
30
  @edit_image = Resources::EditImage.new(http)
@@ -3,18 +3,22 @@
3
3
  module RunApi
4
4
  module Qwen2
5
5
  module Types
6
+ # All Qwen 2 model variants, each dedicated to a single operation type.
6
7
  MODELS = %w[qwen-2-edit-image qwen-2-text-to-image qwen-2-remix-image].freeze
7
8
  EDIT_MODELS = %w[qwen-2-edit-image].freeze
8
9
  TEXT_TO_IMAGE_MODELS = %w[qwen-2-text-to-image].freeze
9
10
  REMIX_IMAGE_MODELS = %w[qwen-2-remix-image].freeze
11
+ # Edit-image aspect ratios include ultra-wide 21:9; narrower set than generation.
10
12
  EDIT_IMAGE_ASPECT_RATIOS = %w[1:1 2:3 3:2 3:4 4:3 9:16 16:9 21:9].freeze
11
13
  TEXT_TO_IMAGE_ASPECT_RATIOS = %w[1:1 3:4 4:3 9:16 16:9].freeze
12
14
  OUTPUT_FORMATS = %w[jpeg png].freeze
13
15
 
16
+ # A single generated image result.
14
17
  class Image < RunApi::Core::BaseModel
15
18
  optional :url, String
16
19
  end
17
20
 
21
+ # Shared task result for all Qwen 2 image operations.
18
22
  class ImageTaskResponse < RunApi::Core::TaskResponse
19
23
  required :id, String
20
24
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -26,6 +30,9 @@ module RunApi
26
30
  class RemixImageResponse < ImageTaskResponse; end
27
31
  class EditImageResponse < ImageTaskResponse; end
28
32
 
33
+ # Narrowed responses returned by +run()+ methods once polling observes
34
+ # +status: "completed"+. +images+ is required so consumers never
35
+ # have to null-check it on a successful task.
29
36
  class CompletedTextToImageResponse < TextToImageResponse
30
37
  required :images, [-> { Image }]
31
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-qwen-2
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,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.5
18
+ version: 0.2.6
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.5
25
+ version: 0.2.6
26
26
  description: The qwen image api Ruby SDK is the language-specific package for Qwen
27
27
  2 on RunAPI. Use this qwen image api package for text-to-image, image editing, and
28
28
  creative production flows when your application needs JSON request bodies, task