runapi-topaz 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: 40f94d07e2d993a379822f44b3a4c56e630472b9ec8a0a882c38d746f223206f
4
- data.tar.gz: f8649bed0ba63f962c14e335546b81dc2d6ec61304b51976309d5bd076e39f23
3
+ metadata.gz: 52dc7160d3ead033cba7dcfd96c3e5b8d2155a76c2f2a7a0ff43b5525a4e6f38
4
+ data.tar.gz: e2ccac89059ab9e7c30353e2ec249a22957fc15eba0dc25d2818d52d703ebf46
5
5
  SHA512:
6
- metadata.gz: 59b8eee6de311173b3cd3159918352d2a6ae98714e3ec99d730dfaad9d27e3be87ac185fd76a6a9f20e2cfcbf3fa04f4a86cd6001c5c44474ee997164f27b3fb
7
- data.tar.gz: 196b238d9eb37a8aecc2574515778dd46469ad2239d9015731cb2599db57e9aadacabfaebedb5797a0930f1fca120d07ea4a352721b7896989ca30139e3401ac
6
+ metadata.gz: 1de31db31fd7c9740230ad62de53cc32e07211e3914e6e0ec3acd45871f3055c0bcb0fd7423b1ba4364796d5f9a120cd1bd07948a7d6f3ceb34ad1ae35864f21
7
+ data.tar.gz: d635d7b485ffe75a77cb1999a4ecbf98310d9f5ae6f745a3035ef1d469b87f5838c9bc0a01d2b4052f12e23787ae4ac0ab4c82443a0a22c03c3aa91ce97344b0
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Topaz API Ruby SDK for RunAPI
1
+ # Topaz Ruby SDK for RunAPI
2
2
 
3
- The topaz api Ruby SDK is the language-specific package for Topaz on RunAPI. Use this topaz api package for image upscale, video upscale, restoration, and production cleanup flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The Topaz Ruby SDK is the language-specific package for Topaz on RunAPI. Use this package for image upscale, video upscale, restoration, and production cleanup workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
- This topaz api README is the Ruby package guide inside the public `topaz-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/topaz; for API reference, use https://runapi.ai/docs#topaz; for SDK docs, use https://runapi.ai/docs#sdk-topaz.
5
+ This README is the Ruby package guide inside the public `topaz-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/topaz; for API reference, use https://runapi.ai/docs#topaz; for SDK docs, use https://runapi.ai/docs#sdk-topaz.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,17 +16,19 @@ gem install runapi-topaz
16
16
  require "runapi-topaz"
17
17
 
18
18
  client = RunApi::Topaz::Client.new
19
- task = client.image_upscales.create(
19
+ task = client.upscale_image.create(
20
20
  # Pass the Topaz JSON request body from https://runapi.ai/docs#topaz.
21
21
  )
22
- status = client.image_upscales.get(task.id)
22
+ status = client.upscale_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::Topaz` error classes when building upscaling jobs, Rails workers, or scripts. The available resources include image upscales, and video upscales. 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::Topaz` error classes when building upscaling jobs, Rails workers, or scripts. The available resources are `upscale_image` and `upscale_video`. 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,24 @@
2
2
 
3
3
  module RunApi
4
4
  module Topaz
5
- class Client
6
- attr_reader :upscale_image, :upscale_video
5
+ # Topaz AI upscaling client for increasing image and video resolution.
6
+ #
7
+ # @example
8
+ # client = RunApi::Topaz::Client.new(api_key: "sk-...")
9
+ # result = client.upscale_image.run(
10
+ # model: "topaz-upscale-image",
11
+ # source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg",
12
+ # upscale_factor: 2
13
+ # )
14
+ # puts result.images.first.url
15
+ class Client < RunApi::Core::Client
16
+ # @return [Resources::UpscaleImage] AI-powered image upscaling (1x, 2x, 4x, 8x).
17
+ attr_reader :upscale_image
18
+ # @return [Resources::UpscaleVideo] AI-powered video upscaling (1x, 2x, 4x).
19
+ attr_reader :upscale_video
7
20
 
8
21
  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)
22
+ super
13
23
  @upscale_image = Resources::UpscaleImage.new(http)
14
24
  @upscale_video = Resources::UpscaleVideo.new(http)
15
25
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Topaz
5
+ CONTRACT = {
6
+ "upscale-image" => {
7
+ "models" => ["topaz-upscale-image"],
8
+ "fields_by_model" => {
9
+ "topaz-upscale-image" => {
10
+ "source_image_url" => {
11
+ "required" => true
12
+ },
13
+ "upscale_factor" => {
14
+ "enum" => [1, 2, 4, 8],
15
+ "required" => true,
16
+ "type" => "integer"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ "upscale-video" => {
22
+ "models" => ["topaz-upscale-video"],
23
+ "fields_by_model" => {
24
+ "topaz-upscale-video" => {
25
+ "source_video_url" => {
26
+ "required" => true
27
+ },
28
+ "upscale_factor" => {
29
+ "enum" => [1, 2, 4],
30
+ "type" => "integer"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }.freeze
36
+ end
37
+ end
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Topaz
5
5
  module Resources
6
+ # AI-powered image upscaling resource.
7
+ # Supports upscale factors of 1x, 2x, 4x, and 8x.
6
8
  class UpscaleImage
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -22,26 +24,13 @@ module RunApi
22
24
 
23
25
  def create(**params)
24
26
  params = compact_params(params)
25
- validate_params!(params)
27
+ validate_contract!(CONTRACT["upscale-image"], params)
26
28
  request(:post, ENDPOINT, body: params)
27
29
  end
28
30
 
29
31
  def get(id)
30
32
  request(:get, "#{ENDPOINT}/#{id}")
31
33
  end
32
-
33
- private
34
-
35
- def validate_params!(params)
36
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_IMAGE_MODEL
37
- raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
38
-
39
- factor = param(params, :upscale_factor)
40
- raise Core::ValidationError, "upscale_factor is required" unless factor
41
- return if Types::UPSCALE_IMAGE_FACTORS.include?(factor)
42
-
43
- raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_IMAGE_FACTORS.join(", ")}"
44
- end
45
34
  end
46
35
  end
47
36
  end
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Topaz
5
5
  module Resources
6
+ # AI-powered video upscaling resource.
7
+ # Supports upscale factors of 1x, 2x, and 4x.
6
8
  class UpscaleVideo
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -22,25 +24,13 @@ module RunApi
22
24
 
23
25
  def create(**params)
24
26
  params = compact_params(params)
25
- validate_params!(params)
27
+ validate_contract!(CONTRACT["upscale-video"], params)
26
28
  request(:post, ENDPOINT, body: params)
27
29
  end
28
30
 
29
31
  def get(id)
30
32
  request(:get, "#{ENDPOINT}/#{id}")
31
33
  end
32
-
33
- private
34
-
35
- def validate_params!(params)
36
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_VIDEO_MODEL
37
- raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
38
-
39
- factor = param(params, :upscale_factor)
40
- return unless factor && !Types::UPSCALE_VIDEO_FACTORS.include?(factor)
41
-
42
- raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_VIDEO_FACTORS.join(", ")}"
43
- end
44
34
  end
45
35
  end
46
36
  end
@@ -2,20 +2,19 @@
2
2
 
3
3
  module RunApi
4
4
  module Topaz
5
+ # Response models for the Topaz upscaling API.
5
6
  module Types
6
- UPSCALE_IMAGE_MODEL = "topaz-upscale-image"
7
- UPSCALE_VIDEO_MODEL = "topaz-upscale-video"
8
- UPSCALE_IMAGE_FACTORS = [1, 2, 4, 8].freeze
9
- UPSCALE_VIDEO_FACTORS = [1, 2, 4].freeze
10
-
7
+ # URL to an upscaled image.
11
8
  class Image < RunApi::Core::BaseModel
12
9
  optional :url, String
13
10
  end
14
11
 
12
+ # URL to an upscaled video.
15
13
  class Video < RunApi::Core::BaseModel
16
14
  optional :url, String
17
15
  end
18
16
 
17
+ # Async image upscaling task result with lifecycle status.
19
18
  class UpscaleImageResponse < RunApi::Core::TaskResponse
20
19
  required :id, String
21
20
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -23,6 +22,7 @@ module RunApi
23
22
  optional :error, String
24
23
  end
25
24
 
25
+ # Async video upscaling task result with lifecycle status.
26
26
  class UpscaleVideoResponse < RunApi::Core::TaskResponse
27
27
  required :id, String
28
28
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -30,10 +30,14 @@ module RunApi
30
30
  optional :error, String
31
31
  end
32
32
 
33
+ # Narrowed response returned by +run+ once polling confirms completion.
34
+ # Images are guaranteed present.
33
35
  class CompletedUpscaleImageResponse < UpscaleImageResponse
34
36
  required :images, [-> { Image }]
35
37
  end
36
38
 
39
+ # Narrowed response returned by +run+ once polling confirms completion.
40
+ # Videos are guaranteed present.
37
41
  class CompletedUpscaleVideoResponse < UpscaleVideoResponse
38
42
  required :videos, [-> { Video }]
39
43
  end
data/lib/runapi/topaz.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "topaz/types"
5
+ require_relative "topaz/contract_gen"
5
6
  require_relative "topaz/resources/upscale_image"
6
7
  require_relative "topaz/resources/upscale_video"
7
8
  require_relative "topaz/client"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-topaz
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 topaz api Ruby SDK is the language-specific package for Topaz on
27
- RunAPI. Use this topaz api package for image upscale, video upscale, restoration,
28
- and production cleanup flows when your application needs JSON request bodies, task
29
- status lookup, and consistent RunAPI errors in Ruby.
25
+ version: 0.2.7
26
+ description: The Topaz Ruby SDK is the language-specific package for Topaz on RunAPI.
27
+ Use this package for image upscale, video upscale, restoration, and production cleanup
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,6 +39,7 @@ files:
39
39
  - lib/runapi-topaz.rb
40
40
  - lib/runapi/topaz.rb
41
41
  - lib/runapi/topaz/client.rb
42
+ - lib/runapi/topaz/contract_gen.rb
42
43
  - lib/runapi/topaz/resources/upscale_image.rb
43
44
  - lib/runapi/topaz/resources/upscale_video.rb
44
45
  - lib/runapi/topaz/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/topaz
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: topaz
49
51
  homepage_uri: https://runapi.ai/models/topaz
50
52
  documentation_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/topaz-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/topaz-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements: []
67
70
  rubygems_version: 4.0.10
68
71
  specification_version: 4
69
- summary: Topaz API Ruby SDK for RunAPI
72
+ summary: Topaz Ruby SDK for RunAPI
70
73
  test_files: []