runapi-topaz 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: fd549096b5cd6f6d44fcfe621bd74d6e67af7be365fc1d3852f7627372a1e46b
4
- data.tar.gz: d9fedb3f0ddd26c9a7c0ed24385e50f37004e3522e42974f84b07392d35062f6
3
+ metadata.gz: 8bb62f2b5c763e463433c6a31953baaf2f0f6fe9d2586898149e759b2b7a4544
4
+ data.tar.gz: 2890b5d76de93833bb898c9d2ad25eee601dc3597db7d35e1f332f3d3499b199
5
5
  SHA512:
6
- metadata.gz: a1092ed17ba3fff61ff5130c47fcaf2e6653059ed2b4caf45b9d7091f1c7a2ae38e71fec07e03dccd24df800f52819c309419e4c070ef3f0855b978632d37af6
7
- data.tar.gz: 80cc131adf8bac5eca114001426c96ecbc461ef09dfcb1a4687d5b8393998ed4172c983a3f08e8a34dcf07eb892b082f46f68a44214748394780ec567483c2f9
6
+ metadata.gz: 52ede417926cb5fffe3af6af0dd5e5a9e00ccb2cbb73ca86be7b963a94ee1dd04c913b4c05817a0ab34c9eafcca34c90bf936fef8fa21ef8f575d3ed03abaf34
7
+ data.tar.gz: 4d0496f468fd8c1277420c461cb7856e61efe269dc17614836c25da379104f42e9574b4b04f8d69885e458956ab60b52e3d1febaf3e62bf22edddc40f3192bf9
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Topaz API Ruby SDK for RunAPI
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.
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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-topaz
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-topaz"
17
+
18
+ client = RunApi::Topaz::Client.new
19
+ task = client.image_upscales.create(
20
+ # Pass the Topaz JSON request body from https://runapi.ai/docs#topaz.
21
+ )
22
+ status = client.image_upscales.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
+ 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
+
29
+ ## Language notes
30
+
31
+ 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.
32
+
33
+ ## Links
34
+
35
+ - Model page: https://runapi.ai/models/topaz
36
+ - SDK docs: https://runapi.ai/docs#sdk-topaz
37
+ - Product docs: https://runapi.ai/docs#topaz
38
+ - Pricing and rate limits: https://runapi.ai/models/topaz/upscale-image
39
+ - Provider comparison: https://runapi.ai/providers/topaz
40
+ - Full catalog: https://runapi.ai/models
41
+ - Repository: https://github.com/runapi-ai/topaz-sdk
42
+
43
+ ## License
44
+
45
+ Licensed under the Apache License, Version 2.0.
@@ -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://example.com/photo.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
@@ -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
 
@@ -34,11 +36,11 @@ module RunApi
34
36
 
35
37
  def validate_params!(params)
36
38
  raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_IMAGE_MODEL
37
- raise Core::ValidationError, "image_url is required" unless param(params, :image_url)
39
+ raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
38
40
 
39
41
  factor = param(params, :upscale_factor)
40
42
  raise Core::ValidationError, "upscale_factor is required" unless factor
41
- return if Types::UPSCALE_IMAGE_FACTORS.include?(factor.to_s)
43
+ return if Types::UPSCALE_IMAGE_FACTORS.include?(factor)
42
44
 
43
45
  raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_IMAGE_FACTORS.join(", ")}"
44
46
  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
 
@@ -34,10 +36,10 @@ module RunApi
34
36
 
35
37
  def validate_params!(params)
36
38
  raise Core::ValidationError, "model is required" unless param(params, :model) == Types::UPSCALE_VIDEO_MODEL
37
- raise Core::ValidationError, "video_url is required" unless param(params, :video_url)
39
+ raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
38
40
 
39
41
  factor = param(params, :upscale_factor)
40
- return unless factor && !Types::UPSCALE_VIDEO_FACTORS.include?(factor.to_s)
42
+ return unless factor && !Types::UPSCALE_VIDEO_FACTORS.include?(factor)
41
43
 
42
44
  raise Core::ValidationError, "upscale_factor must be one of: #{Types::UPSCALE_VIDEO_FACTORS.join(", ")}"
43
45
  end
@@ -2,40 +2,53 @@
2
2
 
3
3
  module RunApi
4
4
  module Topaz
5
+ # Type definitions and constants for the Topaz upscaling API.
5
6
  module Types
6
- UPSCALE_IMAGE_MODEL = "topaz-image-upscale"
7
- UPSCALE_VIDEO_MODEL = "topaz-video-upscale"
8
- UPSCALE_IMAGE_FACTORS = %w[1 2 4 8].freeze
9
- UPSCALE_VIDEO_FACTORS = %w[1 2 4].freeze
7
+ # Image upscaling model slug.
8
+ UPSCALE_IMAGE_MODEL = "topaz-upscale-image"
9
+ # Video upscaling model slug.
10
+ UPSCALE_VIDEO_MODEL = "topaz-upscale-video"
11
+ # Allowed image upscale factors. Higher factors produce larger output but take longer.
12
+ UPSCALE_IMAGE_FACTORS = [1, 2, 4, 8].freeze
13
+ # Allowed video upscale factors. Max 4x (8x is not supported for video).
14
+ UPSCALE_VIDEO_FACTORS = [1, 2, 4].freeze
10
15
 
16
+ # URL to an upscaled image.
11
17
  class Image < RunApi::Core::BaseModel
12
18
  optional :url, String
13
19
  end
14
20
 
21
+ # URL to an upscaled video.
15
22
  class Video < RunApi::Core::BaseModel
16
23
  optional :url, String
17
24
  end
18
25
 
26
+ # Async image upscaling task result with lifecycle status.
19
27
  class UpscaleImageResponse < RunApi::Core::TaskResponse
20
28
  required :id, String
21
29
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
22
- optional :images, [ -> { Image } ]
30
+ optional :images, [-> { Image }]
23
31
  optional :error, String
24
32
  end
25
33
 
34
+ # Async video upscaling task result with lifecycle status.
26
35
  class UpscaleVideoResponse < RunApi::Core::TaskResponse
27
36
  required :id, String
28
37
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
29
- optional :videos, [ -> { Video } ]
38
+ optional :videos, [-> { Video }]
30
39
  optional :error, String
31
40
  end
32
41
 
42
+ # Narrowed response returned by +run+ once polling confirms completion.
43
+ # Images are guaranteed present.
33
44
  class CompletedUpscaleImageResponse < UpscaleImageResponse
34
- required :images, [ -> { Image } ]
45
+ required :images, [-> { Image }]
35
46
  end
36
47
 
48
+ # Narrowed response returned by +run+ once polling confirms completion.
49
+ # Videos are guaranteed present.
37
50
  class CompletedUpscaleVideoResponse < UpscaleVideoResponse
38
- required :videos, [ -> { Video } ]
51
+ required :videos, [-> { Video }]
39
52
  end
40
53
  end
41
54
  end
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.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,22 +15,27 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.4
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.4
26
- description: RunAPI Topaz SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.6
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.
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-topaz.rb
35
40
  - lib/runapi/topaz.rb
36
41
  - lib/runapi/topaz/client.rb
@@ -42,7 +47,7 @@ licenses:
42
47
  - Apache-2.0
43
48
  metadata:
44
49
  homepage_uri: https://runapi.ai/models/topaz
45
- documentation_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/README.md
50
+ documentation_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/ruby/README.md
46
51
  source_code_uri: https://github.com/runapi-ai/topaz-sdk
47
52
  changelog_uri: https://github.com/runapi-ai/topaz-sdk/blob/main/CHANGELOG.md
48
53
  rdoc_options: []
@@ -61,5 +66,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
66
  requirements: []
62
67
  rubygems_version: 4.0.10
63
68
  specification_version: 4
64
- summary: Topaz API SDKs for JavaScript, Ruby, and Go on RunAPI.
69
+ summary: Topaz API Ruby SDK for RunAPI
65
70
  test_files: []