Novita.ai
  1. 基本 API
Novita.ai
  • Novita.ai
  • 账户接口
    • 配置s3配置
      POST
    • 查询s3配置
      GET
    • 删除 s3 配置
      DELETE
    • 用户信息
      GET
  • 基本 API
    • 文字转图像
      POST
    • 图像到图像
      POST
    • 进步
      GET
    • 广告商
      POST
  • 基础 API V3
    • 使用 lcm 将文本转为图像
      POST
    • 使用 lcm 进行图像到图像
      POST
    • 获取异步任务结果
      GET
    • 文字转图像
      POST
    • 图像到图像
      POST
  • 模型 API
    • 同步 civitai 模型
      POST
    • 查询 civitai 模型
      GET
    • 查询模型
      GET
  • 案例 API
    • Upscale
      POST
    • 清除
      POST
    • 外画
      POST
    • 删除背景
      POST
    • 删除文字
      POST
    • 重新想象
      POST
    • 涂鸦
      POST
    • 混合姿势
      POST
    • 替换背景
      POST
    • 替换天空
      POST
    • 恢复面容
      POST
    • 创建图块
      POST
    • 去除水印
      POST
    • 合并面
      POST
    • 替换对象
      POST
    • 图片提示
      POST
    • 制作照片
      POST
    • 要遮罩的图像
      POST
  • 培训 API
    • 获取图片网址
    • 接受学科培训
    • 创建学科培训
    • 创建风格训练
    • 接受风格培训
    • 列出训练任务
  • 视频 API
    • 图像转视频 API
    • 图像到视频运动 API
    • 文本转视频 API
  1. 基本 API

文字转图像

开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
/v2/txt2img
文本到图像端点,只会返回一个task_id。您应该使用 task_id 调用 /v2/progress API 端点以检索图像生成结果。输出以“image/png”格式提供。指导: https: //novita.ai/get-started/Basic_txt2img.html#_1-txt2img-request-with-normal-parameter。
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://dev-cn.your-api-server.com/v2/txt2img' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data-raw '{
  "extra": {
    "enable_nsfw_detection": false
  },
  "prompt": "nsfw, 1girl, (solo:1.1), small breasts, topless, nipples, thongs, thigh, slicked back short hair, half body in pool, outdoor, pool side, very sexy, wet body, modern villa, southern france, soft light, realistic, intricate details, (light freckles:0.5), lightly tanned, professional photography, depth of field, amazing eyes, (smooth hands:1.1), photoshoot, detailed background, professional model, ultra 4k, photorealist, lace panties",
  "negative_prompt": "(badhandv4:1.2),(worst quality:2),(low quality:2),(normal quality:2),lowres,bad anatomy,bad hands,((monochrome)),((grayscale)) watermark,moles, easynegative ng_deepnegative_v1_75t, (oversized head:2), (big head:2), (deformed face:1.5),( blurry face:2), bad eyes, irregular eyes, asymmetric eyes, ugly, teeth, (navel:0.9), artefact, jpg artefact, blurry face, blurry, blurred, pixelated, bad eyes, crossed eyes, blurry eyes, nipple",
  "sampler_name": "DPM++ 2M Karras",
  "batch_size": 1,
  "n_iter": 1,
  "steps": 25,
  "cfg_scale": 7,
  "seed": -1,
  "height": 512,
  "width": 512,
  "model_name": "anyhentai_20_31826.safetensors",
  "restore_faces": false,
  "restore_faces_model": "",
  "sd_vae": "",
  "clip_skip": 1,
  "enable_hr": false,
  "hr_upscaler": "Latent",
  "hr_scale": 1,
  "hr_resize_x": null,
  "hr_resize_y": null,
  "img_expire_ttl": null,
  "sd_refiner": {
    "checkpoint": "sd_xl_refiner_1.0.safetensors",
    "switch_at": null
  },
  "controlnet_units": [
    {
      "model": "",
      "weight": null,
      "input_image": "",
      "module": "none",
      "control_mode": 0,
      "mask": "",
      "resize_mode": 0,
      "processor_res": null,
      "threshold_a": null,
      "threshold_b": null,
      "guidance_start": null,
      "guidance_end": null,
      "pixel_perfect": false
    }
  ]
}'
响应示例响应示例
{
  "code": 0,
  "msg": "",
  "data": {
    "task_id": "d4cf3973-8414-4a5e-aa6f-ef54caf73662",
    "warn": ""
  }
}

请求参数

Header 参数
Authorization
string 
必需
Content-Type
string 
必需
示例值:
application/json
Body 参数application/json
extra
object 
可选
enable_nsfw_detection
boolean 
必需
设置为 true 时,将启用 NSFW 检测,每个生成的图像会产生 0.0015 美元的额外费用。
prompt
string 
必需

肯定提示词,用“,”分隔。如果要使用 LoRA,可以使用参数 filter.types=lora 调用“/v3/model”端点,以检索“sd_name_in_api”字段作为“model_name”。请记住,Lora 模型的格式为“lora:${sd_name}:${weight}”。

negative_prompt
string 
可选
否定提示词,用“,”分隔
sampler_name
string 
必需
这个去噪过程称为采样,因为稳定扩散在每个步骤中都会生成一个新的样本图像。
batch_size
integer 
必需
一代中生成了多少图像。范围:[0, 8]
n_iter
integer 
必需
多少代了。范围:[0, 8]
steps
integer 
必需
将步骤视为图像创建过程的迭代。范围:(0, 50]
cfg_scale
integer 
必需
此设置表示稳定扩散将听取您的提示的程度。范围:(0, 30]
seed
integer 
可选
种子是稳定扩散产生噪声的数字。
height
integer 
必需
图像的高度。范围:(0, 2048]
width
integer 
必需
图像的宽度。范围:(0, 2048]
model_name
string 
必需
稳定扩散模型的名称,您可以使用参数filter.types=checkpoint调用/v3/model端点来检索sd_name_in_api字段作为model_name。
restore_faces
boolean 
可选
启用稳定扩散恢复面插件。
restore_faces_model
string 
可选
人脸恢复算法。-“GFPGAN”旨在开发一种用于现实世界面部恢复的实用算法。它利用封装在预训练人脸 GAN(例如 StyleGAN2)中的丰富多样的先验进行盲脸恢复,请在此处获取指导:https://github.com/TencentARC/GFPGAN;- ‘CodeFormer’是一个基于 Transformer 的预测网络,可以对低质量人脸的全局构成和上下文进行建模以进行编码预测,即使在输入信息严重缺失的情况下也可以恢复与目标人脸非常接近的自然人脸图像,在这里获取指导:https://github.com/sc Zhou/CodeFormer ;
sd_vae
string 
可选
VAE(Variational Auto Encoder),sd_vae 可以在 api /v3/model 中通过查询参数 filter.types=vae 访问,以检索 sd_name 字段作为 sd_vae。
clip_skip
integer 
可选
该参数表示优化期间从底部开始停止的层数,因此clip_skip on 2意味着,在CLIP有12层的SD1.x模型中,您将停止在第10层。
enable_hr
boolean 
可选
雇用。修复功能开关。
hr_upscaler
string 
可选
升级型号名称。人工智能升级器是用大量数据训练的模型。
hr_scale
integer 
可选
图像的放大倍数,如果设置了参数hr_resize_x和hr_resize_y,则该参数将被忽略。
hr_resize_x
null 
可选
目标图像宽度,最大图像尺寸为2048,仅在参数hr_scale=1时生效。
hr_resize_y
null 
可选
目标图像高度,最大图像尺寸为2048,仅在参数hr_scale=1时生效。
img_expire_ttl
null 
可选
图像存储时间(秒)。范围 [0, 604800]
sd_refiner
object 
可选
细化信息以增强图像细节。
checkpoint
string 
必需
switch_at
null 
必需
controlnet_units
array [object {13}] 
控制网。
可选
model
string 
必需
在使用图像进行调节之前,对传递到该单元的图像使用预处理器。***SD 1.5 的控制网络:control_v11e_sd15_ip2p、control_v11e_sd15_shuffle、control_v11f1e_sd15_tile、control_v11f1p_sd15_深度、control_v11p_sd15_canny、control_v11p_sd15_inpaint、control_v11p_sd15_lineart、control_v1 1p_sd15_mlsd、control_v11p_sd15_normalbae、control_v11p_sd15_openpose、control_v11p_sd15_scribble、control_v11p_sd15_seg、control_v11p_sd15_softedge、control_v11p_sd15s2_lineart_anime、ip-adapter-plus-face_sd15、 ip-adapter_sd15_plus,ip-适配器_sd15;***SDXL 控制网:t2i-adapter_diffusers_xl_canny、t2i-adapter_diffusers_xl_depth_midas、t2i-adapter_diffusers_xl_depth_zoe、t2i-adapter_diffusers_xl_lineart、t2i-adapter_diffusers_xl_openpose、t2i-adapter_diff users_xl_sketch、t2i-adapter_xl_canny、t2i-adapter_xl_openpose、t2i-adapter_xl_sketch、ip-adapter_xl
weight
null 
必需
该单位的重量。默认为 1
input_image
string 
必需
输入图像的base64
module
string 
必需
在使用图像进行调节之前,对传递到该单元的图像使用预处理器。
control_mode
integer 
必需
0 表示平衡,1 表示“我的提示更重要”2 表示“ControlNet 更重要”
mask
string 
可选
resize_mode
integer 
可选
processor_res
null 
可选
threshold_a
null 
可选
threshold_b
null 
可选
guidance_start
null 
可选
guidance_end
null 
可选
pixel_perfect
boolean 
可选
示例

返回响应

🟢200成功
application/json
Body
code
integer 
必需
CodeNormal = 0、CodeInternalError = -1、CodeInvalidJSON = 1、CodeModelNotExist = 2、CodeTaskIdNotExist = 3、CodeInvalidAuth = 4、CodeHostUnavailable = 5、CodeParamRangeOutOfLimit = 6、CodeCostBalanceFailure = 7、CodeSamplerNotExist = 8、CodeTimeout = 9
msg
string 
必需
data
object 
必需
task_id
string 
必需
任务 ID,由 /v2/progress 使用
warn
string 
潜在风险的警告消息
可选
上一页
用户信息
下一页
图像到图像
Built with