runapi-z-image 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: e0cc4cee5277c6f3caf58569a36a33c9f3a697637917c9091f4f42a6eaf5ebf3
4
- data.tar.gz: da3efb2dada6fed4c156cf49401d49daa1ffcdeaf7013a8082e9f5c2d5c310f4
3
+ metadata.gz: 58ef3ee01eda999e989ff9f6d08380ae01344598622fbc8b8b7772d703b8dfcb
4
+ data.tar.gz: 824abb45e84e3b97378cae64d29dd0c4b98d8c5cb98edc1705586927e6d44a9a
5
5
  SHA512:
6
- metadata.gz: 75846ad36c5f89f307132964b79bea2b0a8fb05b1ee7774262263e8fc948e785f54af2da3ff9502e0f09c605de728cc7abdbe8339daf57386e3572297bfa5634
7
- data.tar.gz: f5ac2d339056d52006b69cdc5871f0ba024a4e546c9b3db8b7359ca5fb14d5716d2b625d90f46ac28ef6706a92dc5452c45e49bc3d9d95b04c5830d261371c86
6
+ metadata.gz: d9d5f299612e31c1464d3a8118802e0983c6a7a31b6dfae1e885f958f50ae2fa8b71ebbc568d684e34b8f80111f4795f300d98fc3fb88a0c1e7b1a75cd7ba22a
7
+ data.tar.gz: 6561e4c58d7834da030a271a42be3bed8721a43cfb3a0a532d5fbbdaec8a59fd4dff453f24358061bb72f6ca6dae93d24466cf0b940e325798c481390e899167
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
 
@@ -13,13 +13,13 @@ gem install runapi-z-image
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-z-image"
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.
@@ -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::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.
32
32
 
33
33
  ## Links
34
34
 
@@ -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
@@ -16,34 +16,19 @@ module RunApi
16
16
  @http = http
17
17
  end
18
18
 
19
- def run(**params)
20
- task = create(**params)
21
- poll_until_complete { get(task.id) }
19
+ def run(options: nil, **params)
20
+ task = create(options: options, **params)
21
+ poll_until_complete { get(task.id, options: options) }
22
22
  end
23
23
 
24
- def create(**params)
24
+ def create(options: nil, **params)
25
25
  params = compact_params(params)
26
- validate_params!(params)
27
- request(:post, ENDPOINT, body: params)
26
+ validate_contract!(CONTRACT["text-to-image"], params)
27
+ request(:post, ENDPOINT, body: params, options: options)
28
28
  end
29
29
 
30
- def get(id)
31
- request(:get, "#{ENDPOINT}/#{id}")
32
- end
33
-
34
- private
35
-
36
- def validate_params!(params)
37
- raise Core::ValidationError, "model is required" unless param(params, :model)
38
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
39
- raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
40
-
41
- model = param(params, :model)
42
- unless Types::MODELS.include?(model)
43
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::MODELS.join(", ")}"
44
- end
45
-
46
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
30
+ def get(id, options: nil)
31
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
47
32
  end
48
33
  end
49
34
  end
@@ -2,13 +2,8 @@
2
2
 
3
3
  module RunApi
4
4
  module ZImage
5
- # Type definitions and constants for the Z-Image text-to-image API.
5
+ # Response models for the Z-Image text-to-image API.
6
6
  module Types
7
- # Z-Image model slug.
8
- MODELS = %w[z-image].freeze
9
- # Output aspect ratios controlling generated image dimensions.
10
- ASPECT_RATIOS = %w[1:1 4:3 3:4 16:9 9:16].freeze
11
-
12
7
  # URL to a generated image.
13
8
  class Image < RunApi::Core::BaseModel
14
9
  optional :url, String
@@ -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.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 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.3.0
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:
@@ -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: Z-Image API Ruby SDK for RunAPI
71
+ summary: Z-Image Ruby SDK for RunAPI
69
72
  test_files: []