Recraft API

Recraft是一款面向专业设计师、插画师和营销人员的 AI 工具。它包括光栅和矢量图像生成、样式创建、品牌风格和颜色的图像生成、图像矢量化和背景去除。

Generate Image - 文生图

POST https://api.ttapi.io/recraft/images/generations

根据提示词生成一张或者多张图像。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

prompt

string

生成图像描述词 注意:Recraft支持多语言理解能力,但实测英文最佳。

n

int

生成图像数量 默认为1,可选1-6 不同图片数量将扣减不同quota

text_layout

object

文本布局,详见

style

string

官方可选风格,详见 不同风格的quota消耗也不同

substyle

string

官方可选子样式,详见

size

string

图像尺寸,可选范围:

1024x1024

1365x1024

1024x1365

1536x1024

1024x1536

1820x1024

1024x1820

1024x2048

2048x1024

1434x1024

1024x1434

1024x1280

1280x1024

1024x1707

1707x1024 默认:1024x1024

model

string

模型版本,可选范围: recraftv3 recraftv2 默认recraftv3

negative_prompt

string

生成图像中不希望包含的内容

controls

object

用法参考,详见

注意:Recraft生成图像接口为同步返回结果,生成的图像张数越多,接口响应时间越长。

请求示例

import requests

endpoint = "https://api.ttapi.io/recraft/images/generations"

headers = {
    "TT-API-KEY": your_key
}

data = {
    "prompt": "a cute cat",
    "size": "1024x1024",
    "n": 2
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())

返回示例

{
    "status": "SUCCESS",
    "message": "success",
    "data": {
        "quota": "8.00",
        "images": [
            {
                "image_id": "358df2b8-a2b1-4922-9347-694c9358711e",
                "url": "https://img.recraft.ai/vLjB9Y3m_rlotwOY6p2ANi8iNHeF4AxtwnRNLEG9qb0/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/358df2b8-a2b1-4922-9347-694c9358711e"
            },
            {
                "image_id": "815a290d-b5ab-403d-9a9e-abcbdd7b617d",
                "url": "https://img.recraft.ai/ELDttt3Sh74-zCFgLoDMQnJwLe2vlOBg01yhYcGj2Bw/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/815a290d-b5ab-403d-9a9e-abcbdd7b617d"
            }
        ]
    }
}

Image To Image - 图生图

POST https://api.ttapi.io/recraft/images/imageToImage

根据上传图像和提示词生成一张或者多张图像。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

参考图URL

prompt

string

生成图像描述词 注意:Recraft支持多语言理解能力,但实测英文最佳。

strength

number

定义与原始图像的差异,应在0-1之间 其中0表示几乎相同,1表示极不相似

n

int

生成图像数量 默认为1,可选1-6 不同图片数量将扣减不同quota

style

string

官方可选风格,详见 不同风格的quota消耗也不同

substyle

string

官方可选子样式,详见

model

string

模型版本,可选范围: recraftv3 recraftv2 默认recraftv3

negative_prompt

string

生成图像中不希望包含的内容

controls

object

用法参考,详见

Inpaint image - 图像重绘

POST https://api.ttapi.io/recraft/images/inpaint

根据上传图像和提示词生成一张或者多张图像。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

参考图URL

mask

string

需要重绘的图片的URL地址 一张跟原图尺寸一样的黑白通道的蒙版(就是图中只包括黑色与白色) 其中白色部分是重绘圈出来的部分 其余部分是黑色

prompt

string

生成图像描述词 注意:Recraft支持多语言理解能力,但实测英文最佳。

n

int

生成图像数量 默认为1,可选1-6 不同图片数量将扣减不同quota

style

string

官方可选风格,详见 不同风格的quota消耗也不同

substyle

string

官方可选子样式,详见

model

string

模型版本,可选范围: recraftv3 recraftv2 默认recraftv3

negative_prompt

string

生成图像中不希望包含的内容

Replace Background - 背景替换

POST https://api.ttapi.io/recraft/images/replaceBackground

替换图像背景操作,检测图像的背景并根据给出的提示进行修改。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

参考图URL

prompt

string

生成图像描述词 注意:Recraft支持多语言理解能力,但实测英文最佳。

n

int

生成图像数量 默认为1,可选1-6 不同图片数量将扣减不同quota

style

string

官方可选风格,详见 不同风格的quota消耗也不同

substyle

string

官方可选子样式,详见

model

string

模型版本,可选范围: recraftv3 recraftv2 默认recraftv3

negative_prompt

string

生成图像中不希望包含的内容

Vectorize Image - 矢量图像转化

POST https://api.ttapi.io/recraft/images/vectorize

将给定的光栅图像转换为矢量图像。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

图片URL

Remove Background - 删除图片背景

POST https://api.ttapi.io/recraft/images/removeBackground

将给定的图片背景识别并删除。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

图片URL

Crisp Upscale - 清晰放大

POST https://api.ttapi.io/recraft/images/crispUpscale

清晰放大给定图像,提高图像分辨率,使图像更清晰 更干净。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

图片URL

Creative Upscale - 创意放大

POST https://api.ttapi.io/recraft/images/creativeUpscale

增强给定的图像,提高分辨率,重点是细化小细节和面孔。

Headers

Name
Value

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数
类型
是否必须
描述

image

string

图片URL

Last updated

Was this helpful?