runapi-z-image 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: 8d5897ea70dd32d8d473283b3fc553f9b0ef44b45b861548476fe0c291ba011f
4
- data.tar.gz: 8f35b13c1a81f908672f11fdaf0ba5381f7a61635f8c2cf36e6a15337b5bf856
3
+ metadata.gz: c3ba1f1d12e10c898bf7d5395cee0a63f52d103ffe9ff60d617edd9d91189fab
4
+ data.tar.gz: 18fb2a8d3b7f2e5d85b53d60c75828bc824db8a1ac2c24967b9a9dfb8320213d
5
5
  SHA512:
6
- metadata.gz: 559123b0ae56392d7e330ba32292f0279f9b574e5623ed74ffa86502a7c59e0db683e98f814c84843f451abdd5753cce3b91699defd57f8df29a798870bb94cd
7
- data.tar.gz: '09f5c253adb7fdcf239e6e7905cbc699172a7dc1d2e6f8653f794a1f023400920e87ce9b7f05bfa9681d6043c0c8baf9e4be6b2070c5e3b935bc15a4d428ed50'
6
+ metadata.gz: 6427e15c5cb423df4c65bc6d5162a2eef9192b3f6fc1607837c94dcd88c31659c882015221fae47efe12683acafa698a86ad4fddc45a613388518c57856a39da
7
+ data.tar.gz: 016ec72fbf4cb1e7dad8d643178a42040d203e51376d5b11cb1008a4fb07c5cf3f49d7f4c74f3b313777cceaa2cf6bcd36d22c0721085dab5c85c56e093af31d
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Z-Image API Ruby SDK for RunAPI
1
+ # Z-Image Ruby SDK for RunAPI
2
2
 
3
- The z-image api Ruby SDK is the language-specific package for Z-Image on RunAPI. Use this z-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.
3
+ The Z-Image Ruby SDK is the language-specific package for Z-Image 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 z-image api README is the Ruby package guide inside the public `z-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/z-image; for API reference, use https://runapi.ai/docs#z-image; for SDK docs, use https://runapi.ai/docs#sdk-z-image.
5
+ This README is the Ruby package guide inside the public `z-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/z-image; for API reference, use https://runapi.ai/docs#z-image; for SDK docs, use https://runapi.ai/docs#sdk-z-image.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,17 +16,19 @@ gem install runapi-z-image
16
16
  require "runapi-z-image"
17
17
 
18
18
  client = RunApi::ZImage::Client.new
19
- task = client.generations.create(
19
+ task = client.text_to_image.create(
20
20
  # Pass the Z-Image JSON request body from https://runapi.ai/docs#z-image.
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.
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::ZImage` 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::ZImage` 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,14 +2,22 @@
2
2
 
3
3
  module RunApi
4
4
  module ZImage
5
- class Client
5
+ # Z-Image text-to-image generation client.
6
+ #
7
+ # @example
8
+ # client = RunApi::ZImage::Client.new(api_key: "sk-...")
9
+ # result = client.text_to_image.run(
10
+ # model: "z-image",
11
+ # prompt: "A serene Japanese garden at sunrise",
12
+ # aspect_ratio: "16:9"
13
+ # )
14
+ # puts result.images.first.url
15
+ class Client < RunApi::Core::Client
16
+ # @return [Resources::TextToImage] Text-to-image generation with configurable aspect ratio and safety filtering.
6
17
  attr_reader :text_to_image
7
18
 
8
19
  def initialize(api_key: nil, **options)
9
- @api_key = Core::Auth.resolve_api_key(api_key)
10
-
11
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
12
- http = client_options.http_client || Core::HttpClient.new(client_options)
20
+ super
13
21
  @text_to_image = Resources::TextToImage.new(http)
14
22
  end
15
23
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module ZImage
5
+ CONTRACT = {
6
+ "text-to-image" => {
7
+ "models" => ["z-image"],
8
+ "fields_by_model" => {
9
+ "z-image" => {
10
+ "aspect_ratio" => {
11
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16"],
12
+ "required" => true
13
+ },
14
+ "prompt" => {
15
+ "required" => true,
16
+ "min" => 1,
17
+ "max" => 1000,
18
+ "length" => true
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }.freeze
24
+ end
25
+ end
@@ -3,6 +3,7 @@
3
3
  module RunApi
4
4
  module ZImage
5
5
  module Resources
6
+ # Generates images from text prompts with configurable aspect ratio and safety filtering.
6
7
  class TextToImage
7
8
  include RunApi::Core::ResourceHelpers
8
9
 
@@ -22,28 +23,13 @@ module RunApi
22
23
 
23
24
  def create(**params)
24
25
  params = compact_params(params)
25
- validate_params!(params)
26
+ validate_contract!(CONTRACT["text-to-image"], params)
26
27
  request(:post, ENDPOINT, body: params)
27
28
  end
28
29
 
29
30
  def get(id)
30
31
  request(:get, "#{ENDPOINT}/#{id}")
31
32
  end
32
-
33
- private
34
-
35
- def validate_params!(params)
36
- raise Core::ValidationError, "model is required" unless param(params, :model)
37
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
38
- raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
39
-
40
- model = param(params, :model)
41
- unless Types::MODELS.include?(model)
42
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::MODELS.join(", ")}"
43
- end
44
-
45
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
46
- end
47
33
  end
48
34
  end
49
35
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  module RunApi
4
4
  module ZImage
5
+ # Response models for the Z-Image text-to-image API.
5
6
  module Types
6
- MODELS = %w[z-image].freeze
7
- ASPECT_RATIOS = %w[1:1 4:3 3:4 16:9 9:16].freeze
8
-
7
+ # URL to a generated image.
9
8
  class Image < RunApi::Core::BaseModel
10
9
  optional :url, String
11
10
  end
12
11
 
12
+ # Async text-to-image task result with lifecycle status.
13
13
  class TextToImageResponse < RunApi::Core::TaskResponse
14
14
  required :id, String
15
15
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -17,6 +17,8 @@ module RunApi
17
17
  optional :error, String
18
18
  end
19
19
 
20
+ # Narrowed response returned by +run+ once polling confirms completion.
21
+ # Images are guaranteed present.
20
22
  class CompletedTextToImageResponse < TextToImageResponse
21
23
  required :images, [-> { Image }]
22
24
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "z_image/types"
5
+ require_relative "z_image/contract_gen"
5
6
  require_relative "z_image/resources/text_to_image"
6
7
  require_relative "z_image/client"
7
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-z-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
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.5
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.5
26
- description: The z-image api Ruby SDK is the language-specific package for Z-Image
27
- on RunAPI. Use this z-image api package for text-to-image, image editing, and creative
28
- production flows when your application needs JSON request bodies, task status lookup,
29
- and consistent RunAPI errors in Ruby.
25
+ version: 0.2.7
26
+ description: The Z-Image Ruby SDK is the language-specific package for Z-Image on
27
+ 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-z_image.rb
40
40
  - lib/runapi/z_image.rb
41
41
  - lib/runapi/z_image/client.rb
42
+ - lib/runapi/z_image/contract_gen.rb
42
43
  - lib/runapi/z_image/resources/text_to_image.rb
43
44
  - lib/runapi/z_image/types.rb
44
45
  homepage: https://runapi.ai/models/z-image
45
46
  licenses:
46
47
  - Apache-2.0
47
48
  metadata:
49
+ runapi_slug: z-image
48
50
  homepage_uri: https://runapi.ai/models/z-image
49
51
  documentation_uri: https://github.com/runapi-ai/z-image-sdk/blob/main/ruby/README.md
50
52
  source_code_uri: https://github.com/runapi-ai/z-image-sdk
53
+ bug_tracker_uri: https://github.com/runapi-ai/z-image-sdk/issues
51
54
  changelog_uri: https://github.com/runapi-ai/z-image-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: Z-Image API Ruby SDK for RunAPI
71
+ summary: Z-Image Ruby SDK for RunAPI
69
72
  test_files: []