runapi-recraft 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: d5ca7f1872cef0015b8649790c8f17fb3777a59c21e7ddad244e090025de6f77
4
- data.tar.gz: e3669590cf6b8bbb07224cf0c4ba7bc5e1992fb0f7ab2d340c3bac0806531aa7
3
+ metadata.gz: 55e7e0c96e8835ade78091ac2ae8730b97243801959c50b770025cff53c7819f
4
+ data.tar.gz: 9da9fd4900070f8b49748c3f6f8a8b9fd7b8637469c6efe144921592e430080e
5
5
  SHA512:
6
- metadata.gz: e719f5e72e01b541bcf58d977e86b3d6a17fda4489a260a6f3a99a7ddc6ee5cb7de3260a93dd1241326542b3bec9f8a60c70c94d7cdb913225314c46998bde3e
7
- data.tar.gz: 71d5f65fa288b9cfdbad1b5c5ee6eb815db118fa7a91a013af813fa3350e120c2fe23e8f843b4f5ab104037d20a3efb371c91eaaa6259e72b71c49c528ce9af9
6
+ metadata.gz: 100bc2fe7dbfc4c66fa4b083c646fdf6aa629c8f83bf55b038351bcb74ff28d6e0395b5e290e9df26ea2bc5b01e769684c9492d808ecb24537dd956e41a6c5bf
7
+ data.tar.gz: c611577ce0b679934f79729968fa5bf38d8597406b6805d709f0029d48f01fcbaaf2481096fe3a65c0fd967a54e651039f1d31a0e23c338b11d794621d596264
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Recraft API Ruby SDK for RunAPI
2
+
3
+ The recraft api Ruby SDK is the language-specific package for Recraft on RunAPI. Use this recraft 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.
4
+
5
+ This recraft api README is the Ruby package guide inside the public `recraft-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/recraft; for API reference, use https://runapi.ai/docs#recraft; for SDK docs, use https://runapi.ai/docs#sdk-recraft.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-recraft
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-recraft"
17
+
18
+ client = RunApi::Recraft::Client.new
19
+ task = client.upscales.create(
20
+ # Pass the Recraft JSON request body from https://runapi.ai/docs#recraft.
21
+ )
22
+ status = client.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::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.
32
+
33
+ ## Links
34
+
35
+ - Model page: https://runapi.ai/models/recraft
36
+ - SDK docs: https://runapi.ai/docs#sdk-recraft
37
+ - Product docs: https://runapi.ai/docs#recraft
38
+ - Pricing and rate limits: https://runapi.ai/models/recraft/crisp-upscale
39
+ - Provider comparison: https://runapi.ai/providers/recraft
40
+ - Full catalog: https://runapi.ai/models
41
+ - Repository: https://github.com/runapi-ai/recraft-sdk
42
+
43
+ ## License
44
+
45
+ Licensed under the Apache License, Version 2.0.
@@ -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
 
@@ -34,7 +36,7 @@ module RunApi
34
36
 
35
37
  def validate_params!(params)
36
38
  raise Core::ValidationError, "model is required" unless param(params, :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
  model = param(params, :model)
40
42
  unless Types::REMOVE_BACKGROUND_MODELS.include?(model)
@@ -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
 
@@ -34,7 +36,7 @@ module RunApi
34
36
 
35
37
  def validate_params!(params)
36
38
  raise Core::ValidationError, "model is required" unless param(params, :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
  model = param(params, :model)
40
42
  unless Types::UPSCALE_IMAGE_MODELS.include?(model)
@@ -2,23 +2,30 @@
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 }
16
- optional :images, [ -> { Image } ]
21
+ optional :images, [-> { Image }]
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
- required :images, [ -> { Image } ]
28
+ required :images, [-> { Image }]
22
29
  end
23
30
  end
24
31
  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.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 Recraft SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.6
26
+ description: The recraft api Ruby SDK is the language-specific package for Recraft
27
+ on RunAPI. Use this recraft 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.
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-recraft.rb
35
40
  - lib/runapi/recraft.rb
36
41
  - lib/runapi/recraft/client.rb
@@ -42,7 +47,7 @@ licenses:
42
47
  - Apache-2.0
43
48
  metadata:
44
49
  homepage_uri: https://runapi.ai/models/recraft
45
- documentation_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/README.md
50
+ documentation_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/ruby/README.md
46
51
  source_code_uri: https://github.com/runapi-ai/recraft-sdk
47
52
  changelog_uri: https://github.com/runapi-ai/recraft-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: Recraft API SDKs for JavaScript, Ruby, and Go on RunAPI.
69
+ summary: Recraft API Ruby SDK for RunAPI
65
70
  test_files: []