runapi-recraft 0.2.5 → 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: ac78d7e6f131188a636f5e2a83ffa3438ceb02d00275c558375c1000980ae43e
4
- data.tar.gz: bf40d14ed407faf3c15250c2c1778f37e5f342c904efa20374be1f8d0c80446b
3
+ metadata.gz: 55e7e0c96e8835ade78091ac2ae8730b97243801959c50b770025cff53c7819f
4
+ data.tar.gz: 9da9fd4900070f8b49748c3f6f8a8b9fd7b8637469c6efe144921592e430080e
5
5
  SHA512:
6
- metadata.gz: e9cedf23b2a3730afe9a2bfeb3fa7fbc819ea2935524cbdce26e25a412f301c9c7128f63c213da60e45378339c1da35d02cf7c2568d42ac91e253370ed149960
7
- data.tar.gz: 41c554461a6c770ecacfca8536440dec5d4b671438cd56e28a0fc9f8ffb6703ec669dd642805e48e71731d8c60bfd7afd78bbcc481335601a6f141d2a6a67c36
6
+ metadata.gz: 100bc2fe7dbfc4c66fa4b083c646fdf6aa629c8f83bf55b038351bcb74ff28d6e0395b5e290e9df26ea2bc5b01e769684c9492d808ecb24537dd956e41a6c5bf
7
+ data.tar.gz: c611577ce0b679934f79729968fa5bf38d8597406b6805d709f0029d48f01fcbaaf2481096fe3a65c0fd967a54e651039f1d31a0e23c338b11d794621d596264
data/README.md CHANGED
@@ -24,6 +24,8 @@ status = client.upscales.get(task.id)
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
31
  Use Ruby keyword arguments and the `RunApi::Recraft` error classes when building image jobs, Rails workers, or scripts. The available resources include upscales, and background removals. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
@@ -2,14 +2,30 @@
2
2
 
3
3
  module RunApi
4
4
  module Recraft
5
- class Client
6
- attr_reader :upscale_image, :remove_background
5
+ # Recraft image post-processing API client.
6
+ #
7
+ # Provides AI-powered image upscaling and background removal.
8
+ #
9
+ # @example
10
+ # client = RunApi::Recraft::Client.new(api_key: "your-api-key")
11
+ #
12
+ # upscaled = client.upscale_image.run(
13
+ # model: "recraft-crisp-upscale",
14
+ # source_image_url: "https://example.com/photo.jpg"
15
+ # )
16
+ #
17
+ # cutout = client.remove_background.run(
18
+ # model: "recraft-remove-background",
19
+ # source_image_url: "https://example.com/photo.jpg"
20
+ # )
21
+ class Client < RunApi::Core::Client
22
+ # @return [Resources::UpscaleImage] AI-powered image upscaling operations.
23
+ attr_reader :upscale_image
24
+ # @return [Resources::RemoveBackground] Background removal operations.
25
+ attr_reader :remove_background
7
26
 
8
27
  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)
28
+ super
13
29
  @upscale_image = Resources::UpscaleImage.new(http)
14
30
  @remove_background = Resources::RemoveBackground.new(http)
15
31
  end
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Recraft
5
5
  module Resources
6
+ # Background removal resource.
7
+ # Produces a transparent cutout by removing the image background.
6
8
  class RemoveBackground
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Recraft
5
5
  module Resources
6
+ # AI-powered image upscaling resource.
7
+ # Enhance image resolution while preserving detail.
6
8
  class UpscaleImage
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -2,14 +2,19 @@
2
2
 
3
3
  module RunApi
4
4
  module Recraft
5
+ # Type definitions and constants for the Recraft image processing API.
5
6
  module Types
7
+ # Crisp upscaling model that enhances resolution while preserving detail.
6
8
  UPSCALE_IMAGE_MODELS = %w[recraft-crisp-upscale].freeze
9
+ # Background removal model that isolates the foreground subject.
7
10
  REMOVE_BACKGROUND_MODELS = %w[recraft-remove-background].freeze
8
11
 
12
+ # URL to a processed image (upscaled or background-removed).
9
13
  class Image < RunApi::Core::BaseModel
10
14
  optional :url, String
11
15
  end
12
16
 
17
+ # Async image task result shared by upscale and background removal operations.
13
18
  class ImageTaskResponse < RunApi::Core::TaskResponse
14
19
  required :id, String
15
20
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -17,6 +22,8 @@ module RunApi
17
22
  optional :error, String
18
23
  end
19
24
 
25
+ # Narrowed response returned by +run+ once polling confirms completion.
26
+ # Images are guaranteed present.
20
27
  class CompletedImageTaskResponse < ImageTaskResponse
21
28
  required :images, [-> { Image }]
22
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-recraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.5
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.5
25
+ version: 0.2.6
26
26
  description: The recraft api Ruby SDK is the language-specific package for Recraft
27
27
  on RunAPI. Use this recraft api package for text-to-image, image editing, and creative
28
28
  production flows when your application needs JSON request bodies, task status lookup,