runapi-recraft 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 +4 -4
- data/README.md +7 -7
- data/lib/runapi/recraft/client.rb +2 -2
- data/lib/runapi/recraft/contract_gen.rb +28 -0
- data/lib/runapi/recraft/resources/remove_background.rb +8 -20
- data/lib/runapi/recraft/resources/upscale_image.rb +8 -20
- data/lib/runapi/recraft/types.rb +0 -5
- data/lib/runapi/recraft.rb +2 -0
- metadata +12 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c2b2912ab879d8963f9509e01b310536fdc90a037c93d6cd015ae73cde2cf10
|
|
4
|
+
data.tar.gz: be332c3935373d34ce7f75a7ae56e0c5737b3ef1598512baa4366e26ef1afbe4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a77247d24f83011ed6f68409d824803f51761047e7c782ec026f623eb0124fae7d273514e051bcff302eefbc4b4e294b5732bf7b206d59c8767da12cecdd3ab5
|
|
7
|
+
data.tar.gz: 27ee47c83816546c004fb2a2829d27baa9efec25f3b0ce075c3a650fa66295ff3143af107c0238d3b0be632d34099d9adcedea4dc0502c1104318d6ec47a98a5
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Recraft
|
|
1
|
+
# Recraft Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Recraft Ruby SDK is the language-specific package for Recraft 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
|
|
5
|
+
This 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
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -13,13 +13,13 @@ gem install runapi-recraft
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
require "runapi
|
|
16
|
+
require "runapi/recraft"
|
|
17
17
|
|
|
18
18
|
client = RunApi::Recraft::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.upscale_image.create(
|
|
20
20
|
# Pass the Recraft JSON request body from https://runapi.ai/docs#recraft.
|
|
21
21
|
)
|
|
22
|
-
status = client.
|
|
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.
|
|
@@ -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::Recraft` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::Recraft` error classes when building image jobs, Rails workers, or scripts. The available resources are `upscale_image` and `remove_background`. 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
|
|
|
@@ -11,12 +11,12 @@ module RunApi
|
|
|
11
11
|
#
|
|
12
12
|
# upscaled = client.upscale_image.run(
|
|
13
13
|
# model: "recraft-crisp-upscale",
|
|
14
|
-
# source_image_url: "https://
|
|
14
|
+
# source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg"
|
|
15
15
|
# )
|
|
16
16
|
#
|
|
17
17
|
# cutout = client.remove_background.run(
|
|
18
18
|
# model: "recraft-remove-background",
|
|
19
|
-
# source_image_url: "https://
|
|
19
|
+
# source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg"
|
|
20
20
|
# )
|
|
21
21
|
class Client < RunApi::Core::Client
|
|
22
22
|
# @return [Resources::UpscaleImage] AI-powered image upscaling operations.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Recraft
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"remove-background" => {
|
|
7
|
+
"models" => ["recraft-remove-background"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"recraft-remove-background" => {
|
|
10
|
+
"source_image_url" => {
|
|
11
|
+
"required" => true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"upscale-image" => {
|
|
17
|
+
"models" => ["recraft-crisp-upscale"],
|
|
18
|
+
"fields_by_model" => {
|
|
19
|
+
"recraft-crisp-upscale" => {
|
|
20
|
+
"source_image_url" => {
|
|
21
|
+
"required" => true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}.freeze
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -17,31 +17,19 @@ module RunApi
|
|
|
17
17
|
@http = http
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def run(**params)
|
|
21
|
-
task = create(**params)
|
|
22
|
-
poll_until_complete { get(task.id) }
|
|
20
|
+
def run(options: nil, **params)
|
|
21
|
+
task = create(options: options, **params)
|
|
22
|
+
poll_until_complete { get(task.id, options: options) }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def create(**params)
|
|
25
|
+
def create(options: nil, **params)
|
|
26
26
|
params = compact_params(params)
|
|
27
|
-
|
|
28
|
-
request(:post, ENDPOINT, body: params)
|
|
27
|
+
validate_contract!(CONTRACT["remove-background"], params)
|
|
28
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def get(id)
|
|
32
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def validate_params!(params)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
39
|
-
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
40
|
-
|
|
41
|
-
model = param(params, :model)
|
|
42
|
-
unless Types::REMOVE_BACKGROUND_MODELS.include?(model)
|
|
43
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::REMOVE_BACKGROUND_MODELS.join(", ")}"
|
|
44
|
-
end
|
|
31
|
+
def get(id, options: nil)
|
|
32
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
45
33
|
end
|
|
46
34
|
end
|
|
47
35
|
end
|
|
@@ -17,31 +17,19 @@ module RunApi
|
|
|
17
17
|
@http = http
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def run(**params)
|
|
21
|
-
task = create(**params)
|
|
22
|
-
poll_until_complete { get(task.id) }
|
|
20
|
+
def run(options: nil, **params)
|
|
21
|
+
task = create(options: options, **params)
|
|
22
|
+
poll_until_complete { get(task.id, options: options) }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def create(**params)
|
|
25
|
+
def create(options: nil, **params)
|
|
26
26
|
params = compact_params(params)
|
|
27
|
-
|
|
28
|
-
request(:post, ENDPOINT, body: params)
|
|
27
|
+
validate_contract!(CONTRACT["upscale-image"], params)
|
|
28
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def get(id)
|
|
32
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def validate_params!(params)
|
|
38
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
39
|
-
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
40
|
-
|
|
41
|
-
model = param(params, :model)
|
|
42
|
-
unless Types::UPSCALE_IMAGE_MODELS.include?(model)
|
|
43
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::UPSCALE_IMAGE_MODELS.join(", ")}"
|
|
44
|
-
end
|
|
31
|
+
def get(id, options: nil)
|
|
32
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
45
33
|
end
|
|
46
34
|
end
|
|
47
35
|
end
|
data/lib/runapi/recraft/types.rb
CHANGED
|
@@ -4,11 +4,6 @@ module RunApi
|
|
|
4
4
|
module Recraft
|
|
5
5
|
# Type definitions and constants for the Recraft image processing API.
|
|
6
6
|
module Types
|
|
7
|
-
# Crisp upscaling model that enhances resolution while preserving detail.
|
|
8
|
-
UPSCALE_IMAGE_MODELS = %w[recraft-crisp-upscale].freeze
|
|
9
|
-
# Background removal model that isolates the foreground subject.
|
|
10
|
-
REMOVE_BACKGROUND_MODELS = %w[recraft-remove-background].freeze
|
|
11
|
-
|
|
12
7
|
# URL to a processed image (upscaled or background-removed).
|
|
13
8
|
class Image < RunApi::Core::BaseModel
|
|
14
9
|
optional :url, String
|
data/lib/runapi/recraft.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "runapi/core"
|
|
3
4
|
require_relative "recraft/types"
|
|
5
|
+
require_relative "recraft/contract_gen"
|
|
4
6
|
require_relative "recraft/resources/upscale_image"
|
|
5
7
|
require_relative "recraft/resources/remove_background"
|
|
6
8
|
require_relative "recraft/client"
|
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
|
+
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.
|
|
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.
|
|
26
|
-
description: The
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
version: 0.3.0
|
|
26
|
+
description: The Recraft Ruby SDK is the language-specific package for Recraft 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,6 +39,7 @@ files:
|
|
|
39
39
|
- lib/runapi-recraft.rb
|
|
40
40
|
- lib/runapi/recraft.rb
|
|
41
41
|
- lib/runapi/recraft/client.rb
|
|
42
|
+
- lib/runapi/recraft/contract_gen.rb
|
|
42
43
|
- lib/runapi/recraft/resources/remove_background.rb
|
|
43
44
|
- lib/runapi/recraft/resources/upscale_image.rb
|
|
44
45
|
- lib/runapi/recraft/types.rb
|
|
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/recraft
|
|
|
46
47
|
licenses:
|
|
47
48
|
- Apache-2.0
|
|
48
49
|
metadata:
|
|
50
|
+
runapi_slug: recraft
|
|
49
51
|
homepage_uri: https://runapi.ai/models/recraft
|
|
50
52
|
documentation_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/ruby/README.md
|
|
51
53
|
source_code_uri: https://github.com/runapi-ai/recraft-sdk
|
|
54
|
+
bug_tracker_uri: https://github.com/runapi-ai/recraft-sdk/issues
|
|
52
55
|
changelog_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/CHANGELOG.md
|
|
53
56
|
rdoc_options: []
|
|
54
57
|
require_paths:
|
|
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
67
|
- !ruby/object:Gem::Version
|
|
65
68
|
version: '0'
|
|
66
69
|
requirements: []
|
|
67
|
-
rubygems_version: 4.0.
|
|
70
|
+
rubygems_version: 4.0.17
|
|
68
71
|
specification_version: 4
|
|
69
|
-
summary: Recraft
|
|
72
|
+
summary: Recraft Ruby SDK for RunAPI
|
|
70
73
|
test_files: []
|