runapi-qwen-2 0.2.4 → 0.2.6

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: 2c78ff54d710cf9de225f0f6abab5f57503946872e382bf780dd7084d630801a
4
- data.tar.gz: 93ca839ada0fc05d7c99fcbed4cf023e1c837163266968da9691769e2f241e99
3
+ metadata.gz: f7cbfba501dd88b37a82629dee1237753f030d6d92a06faac41f6165985aed21
4
+ data.tar.gz: ec3086cde57f139b0621c21c4e33e18a32aefbaf96be7f53c9757ddefb2631a4
5
5
  SHA512:
6
- metadata.gz: 9b753024a71658d987ec33b0524ef2cdf7d437c5ae0604b612be932b6d9bcec63dd90722b07d2e22088aad31bf4a58345a97696ab0da5a956eab585002fe097d
7
- data.tar.gz: a61c665168372a5b982ff68f5eea4243c70480cea9bac062645107f4dd08825b677c6bc421379951e334c609dac6d813e09c8ad8c013e3ac89c3b35ba48b70db
6
+ metadata.gz: c98213aac1b753e131550119533febb83cbf2e7543479750074458085e54d5be05772018d511f0cb3011aa70c55bbe1d53bce4691b410cfdea7758ade3c4f840
7
+ data.tar.gz: 7f564584fcde1efed7db34abf0a606d36ca59661b496f449cdf00d8137d9a91c32765e5289e357ed15a58627424dbf0ff91ee1a3335c5c6963045ae388550be8
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Qwen Image API Ruby SDK for RunAPI
2
+
3
+ The qwen image api Ruby SDK is the language-specific package for Qwen 2 on RunAPI. Use this qwen image 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.
4
+
5
+ This qwen image api README is the Ruby package guide inside the public `qwen2-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/qwen-2; for API reference, use https://runapi.ai/docs#qwen-2; for SDK docs, use https://runapi.ai/docs#sdk-qwen-2.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-qwen2
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-qwen2"
17
+
18
+ client = RunApi::Qwen2::Client.new
19
+ task = client.generations.create(
20
+ # Pass the Qwen 2 JSON request body from https://runapi.ai/docs#qwen-2.
21
+ )
22
+ status = client.generations.get(task.id)
23
+ ```
24
+
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
+
27
+ ## Language notes
28
+
29
+ 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.
30
+
31
+ ## Links
32
+
33
+ - Model page: https://runapi.ai/models/qwen-2
34
+ - SDK docs: https://runapi.ai/docs#sdk-qwen-2
35
+ - Product docs: https://runapi.ai/docs#qwen-2
36
+ - Pricing and rate limits: https://runapi.ai/models/qwen-2/text-to-image
37
+ - Provider comparison: https://runapi.ai/providers/alibaba
38
+ - Full catalog: https://runapi.ai/models
39
+ - Repository: https://github.com/runapi-ai/qwen2-sdk
40
+
41
+ ## License
42
+
43
+ Licensed under the Apache License, Version 2.0.
@@ -2,18 +2,18 @@
2
2
 
3
3
  module RunApi
4
4
  module Qwen2
5
- # Qwen2 text-to-image, image-to-image, and edit-image API client.
5
+ # Qwen2 text-to-image, remix-image, and edit-image API client.
6
6
  #
7
7
  # @example
8
8
  # client = RunApi::Qwen2::Client.new(api_key: "your-api-key")
9
9
  # result = client.edit_image.run(
10
- # model: "qwen-2-image-edit",
10
+ # model: "qwen-2-edit-image",
11
11
  # prompt: "Replace the background with a neon-lit city skyline",
12
- # image_url: "https://example.com/input.jpg"
12
+ # source_image_url: "https://cdn.runapi.ai/public/samples/input.jpg"
13
13
  # )
14
14
  class Client
15
- # @return [Resources::TextToImage, Resources::ImageToImage, Resources::EditImage] Image operations.
16
- attr_reader :text_to_image, :image_to_image, :edit_image
15
+ # @return [Resources::TextToImage, Resources::RemixImage, Resources::EditImage] Image operations.
16
+ attr_reader :text_to_image, :remix_image, :edit_image
17
17
 
18
18
  def initialize(api_key: nil, **options)
19
19
  @api_key = Core::Auth.resolve_api_key(api_key)
@@ -21,7 +21,7 @@ module RunApi
21
21
  client_options = Core::ClientOptions.new(api_key: @api_key, **options)
22
22
  http = client_options.http_client || Core::HttpClient.new(client_options)
23
23
  @text_to_image = Resources::TextToImage.new(http)
24
- @image_to_image = Resources::ImageToImage.new(http)
24
+ @remix_image = Resources::RemixImage.new(http)
25
25
  @edit_image = Resources::EditImage.new(http)
26
26
  end
27
27
  end
@@ -48,14 +48,14 @@ module RunApi
48
48
  def validate_params!(params)
49
49
  raise Core::ValidationError, "model is required" unless param(params, :model)
50
50
  raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
51
- raise Core::ValidationError, "image_url is required" unless param(params, :image_url)
51
+ raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
52
52
 
53
53
  model = param(params, :model)
54
54
  unless Types::EDIT_MODELS.include?(model)
55
55
  raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::EDIT_MODELS.join(", ")}"
56
56
  end
57
57
 
58
- validate_optional!(params, :image_size, Types::IMAGE_SIZES)
58
+ validate_optional!(params, :aspect_ratio, Types::EDIT_IMAGE_ASPECT_RATIOS)
59
59
  validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
60
60
  end
61
61
  end
@@ -3,42 +3,42 @@
3
3
  module RunApi
4
4
  module Qwen2
5
5
  module Resources
6
- # Qwen2 image-to-image resource. Transforms images with natural-language prompts.
7
- class ImageToImage
6
+ # Qwen2 remix-image resource. Creates prompt-guided variations from a source image.
7
+ class RemixImage
8
8
  include RunApi::Core::ResourceHelpers
9
9
 
10
- ENDPOINT = "/api/v1/qwen_2/image_to_image"
10
+ ENDPOINT = "/api/v1/qwen_2/remix_image"
11
11
 
12
- RESPONSE_CLASS = Types::ImageToImageResponse
13
- COMPLETED_RESPONSE_CLASS = Types::CompletedImageToImageResponse
12
+ RESPONSE_CLASS = Types::RemixImageResponse
13
+ COMPLETED_RESPONSE_CLASS = Types::CompletedRemixImageResponse
14
14
 
15
15
  def initialize(http)
16
16
  @http = http
17
17
  end
18
18
 
19
- # Transform an image and wait until complete.
19
+ # Remix an image and wait until complete.
20
20
  #
21
- # @param params [Hash] image-to-image parameters
22
- # @return [RunApi::Qwen2::Types::CompletedImageToImageResponse] completed image-to-image result
21
+ # @param params [Hash] remix-image parameters
22
+ # @return [RunApi::Qwen2::Types::CompletedRemixImageResponse] completed remix-image result
23
23
  def run(**params)
24
24
  task = create(**params)
25
25
  poll_until_complete { get(task.id) }
26
26
  end
27
27
 
28
- # Create an image-to-image task.
28
+ # Create a remix-image task.
29
29
  #
30
- # @param params [Hash] image-to-image parameters
31
- # @return [RunApi::Qwen2::Types::ImageToImageResponse] task creation result with id
30
+ # @param params [Hash] remix-image parameters
31
+ # @return [RunApi::Qwen2::Types::RemixImageResponse] task creation result with id
32
32
  def create(**params)
33
33
  params = compact_params(params)
34
34
  validate_params!(params)
35
35
  request(:post, ENDPOINT, body: params)
36
36
  end
37
37
 
38
- # Get image-to-image status by task ID.
38
+ # Get remix-image status by task ID.
39
39
  #
40
40
  # @param id [String] task ID
41
- # @return [RunApi::Qwen2::Types::ImageToImageResponse] current image-to-image status
41
+ # @return [RunApi::Qwen2::Types::RemixImageResponse] current remix-image status
42
42
  def get(id)
43
43
  request(:get, "#{ENDPOINT}/#{id}")
44
44
  end
@@ -48,11 +48,11 @@ module RunApi
48
48
  def validate_params!(params)
49
49
  raise Core::ValidationError, "model is required" unless param(params, :model)
50
50
  raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
51
- raise Core::ValidationError, "image_url is required" unless param(params, :image_url)
51
+ raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
52
52
 
53
53
  model = param(params, :model)
54
- unless Types::IMAGE_TO_IMAGE_MODELS.include?(model)
55
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::IMAGE_TO_IMAGE_MODELS.join(", ")}"
54
+ unless Types::REMIX_IMAGE_MODELS.include?(model)
55
+ raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::REMIX_IMAGE_MODELS.join(", ")}"
56
56
  end
57
57
 
58
58
  validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
@@ -53,7 +53,7 @@ module RunApi
53
53
  raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::TEXT_TO_IMAGE_MODELS.join(", ")}"
54
54
  end
55
55
 
56
- validate_optional!(params, :image_size, Types::QWEN_IMAGE_SIZES)
56
+ validate_optional!(params, :aspect_ratio, Types::TEXT_TO_IMAGE_ASPECT_RATIOS)
57
57
  validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
58
58
  end
59
59
  end
@@ -3,12 +3,12 @@
3
3
  module RunApi
4
4
  module Qwen2
5
5
  module Types
6
- MODELS = %w[qwen-2-image-edit qwen-2-text-to-image qwen-2-image-to-image].freeze
7
- EDIT_MODELS = %w[qwen-2-image-edit].freeze
6
+ MODELS = %w[qwen-2-edit-image qwen-2-text-to-image qwen-2-remix-image].freeze
7
+ EDIT_MODELS = %w[qwen-2-edit-image].freeze
8
8
  TEXT_TO_IMAGE_MODELS = %w[qwen-2-text-to-image].freeze
9
- IMAGE_TO_IMAGE_MODELS = %w[qwen-2-image-to-image].freeze
10
- IMAGE_SIZES = %w[1:1 2:3 3:2 3:4 4:3 9:16 16:9 21:9].freeze
11
- QWEN_IMAGE_SIZES = %w[square square_hd portrait_4_3 portrait_16_9 landscape_4_3 landscape_16_9].freeze
9
+ REMIX_IMAGE_MODELS = %w[qwen-2-remix-image].freeze
10
+ EDIT_IMAGE_ASPECT_RATIOS = %w[1:1 2:3 3:2 3:4 4:3 9:16 16:9 21:9].freeze
11
+ TEXT_TO_IMAGE_ASPECT_RATIOS = %w[1:1 3:4 4:3 9:16 16:9].freeze
12
12
  OUTPUT_FORMATS = %w[jpeg png].freeze
13
13
 
14
14
  class Image < RunApi::Core::BaseModel
@@ -18,24 +18,24 @@ module RunApi
18
18
  class ImageTaskResponse < RunApi::Core::TaskResponse
19
19
  required :id, String
20
20
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
21
- optional :images, [ -> { Image } ]
21
+ optional :images, [-> { Image }]
22
22
  optional :error, String
23
23
  end
24
24
 
25
25
  class TextToImageResponse < ImageTaskResponse; end
26
- class ImageToImageResponse < ImageTaskResponse; end
26
+ class RemixImageResponse < ImageTaskResponse; end
27
27
  class EditImageResponse < ImageTaskResponse; end
28
28
 
29
29
  class CompletedTextToImageResponse < TextToImageResponse
30
- required :images, [ -> { Image } ]
30
+ required :images, [-> { Image }]
31
31
  end
32
32
 
33
- class CompletedImageToImageResponse < ImageToImageResponse
34
- required :images, [ -> { Image } ]
33
+ class CompletedRemixImageResponse < RemixImageResponse
34
+ required :images, [-> { Image }]
35
35
  end
36
36
 
37
37
  class CompletedEditImageResponse < EditImageResponse
38
- required :images, [ -> { Image } ]
38
+ required :images, [-> { Image }]
39
39
  end
40
40
  end
41
41
  end
data/lib/runapi/qwen_2.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "runapi/core"
4
4
  require_relative "qwen_2/types"
5
5
  require_relative "qwen_2/resources/text_to_image"
6
- require_relative "qwen_2/resources/image_to_image"
6
+ require_relative "qwen_2/resources/remix_image"
7
7
  require_relative "qwen_2/resources/edit_image"
8
8
  require_relative "qwen_2/client"
9
9
 
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.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,27 +15,32 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.4
18
+ version: 0.2.5
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.4
26
- description: RunAPI Qwen 2 SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.5
26
+ description: The qwen image api Ruby SDK is the language-specific package for Qwen
27
+ 2 on RunAPI. Use this qwen image api package for text-to-image, image editing, and
28
+ creative production flows when your application needs JSON request bodies, task
29
+ status lookup, and consistent RunAPI errors in Ruby.
27
30
  email:
28
31
  - contact@runapi.ai
29
32
  executables: []
30
33
  extensions: []
31
- extra_rdoc_files: []
34
+ extra_rdoc_files:
35
+ - README.md
32
36
  files:
33
37
  - LICENSE
38
+ - README.md
34
39
  - lib/runapi-qwen_2.rb
35
40
  - lib/runapi/qwen_2.rb
36
41
  - lib/runapi/qwen_2/client.rb
37
42
  - lib/runapi/qwen_2/resources/edit_image.rb
38
- - lib/runapi/qwen_2/resources/image_to_image.rb
43
+ - lib/runapi/qwen_2/resources/remix_image.rb
39
44
  - lib/runapi/qwen_2/resources/text_to_image.rb
40
45
  - lib/runapi/qwen_2/types.rb
41
46
  homepage: https://runapi.ai/models/qwen-2
@@ -43,7 +48,7 @@ licenses:
43
48
  - Apache-2.0
44
49
  metadata:
45
50
  homepage_uri: https://runapi.ai/models/qwen-2
46
- documentation_uri: https://github.com/runapi-ai/qwen-2-sdk/blob/main/README.md
51
+ documentation_uri: https://github.com/runapi-ai/qwen-2-sdk/blob/main/ruby/README.md
47
52
  source_code_uri: https://github.com/runapi-ai/qwen-2-sdk
48
53
  changelog_uri: https://github.com/runapi-ai/qwen-2-sdk/blob/main/CHANGELOG.md
49
54
  rdoc_options: []
@@ -62,5 +67,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
67
  requirements: []
63
68
  rubygems_version: 4.0.10
64
69
  specification_version: 4
65
- summary: Qwen 2 API SDKs for JavaScript, Ruby, and Go on RunAPI.
70
+ summary: Qwen Image API Ruby SDK for RunAPI
66
71
  test_files: []