OpenAI 全球独家总代
  1. SDXL
OpenAI 全球独家总代
  • 发出请求
  • 模型接口
    • 聊天接口(Chat)
      • 聊天接口
      • gpts
      • gemini-pro
      • gpt-4-all(分析图片)
      • gpt-4-vision-preview
    • 自动补全接口(Completions)
      • 内容补全接口
    • 图像接口(Images)
      • DALL·E 3
      • gpt-4-all(生成图片)
    • 向量生成接口(Embeddings)
      • 创建嵌入
    • 音频接口(Audio)
      • 创建转录
      • 创建翻译
      • TTS文本转语音
    • MJ图像接口
      • 补充 - 其他参数以及回调
      • InsightFace任务提交
        • 提交swap_face任务
      • 任务提交
        • 执行动作
        • 提交Blend任务
        • 提交Describe任务
        • 提交Imagine任务
        • 提交Modal
        • 提交Shorten任务
      • 任务查询
        • 查询所有任务
        • 根据ID列表查询任务
        • 分页查询任务
        • 查询任务队列
        • 取消任务
        • 指定ID获取任务
        • 获取任务图片的seed(需设置mj或niji的私信ID)
    • Suno音乐接口
      • GoAmzAI格式
        • v3.5
          • 生成音乐
          • 获取音乐
        • v3.0
          • 生成音乐
          • 获取音乐
      • 官网原生格式(v2)
        • 官网格式
        • 所有接口
          • 音乐链接转成suno(upload)
          • 音乐生成(generations)
          • 查询任务(feed)
        • 场景1 生成自定义音乐(带歌词)
          • 音乐生成(generations)
          • 查询任务(feed)
        • 场景 2 通过提示词直接生成音乐(带歌词)
          • 音乐生成(generations)
          • 查询任务(feed)
        • 场景 4 通过提示词直接生成音乐(纯音乐)
          • 音乐生成(generations)
          • 查询任务(feed)
        • 场景3 生成自定义音乐(纯音乐)
          • 音乐生成(generations)
          • 查询任务(feed)
        • 场景 5 上传自定义音频并续写
          • 续写自定义音频步骤介绍
          • 音乐链接转成suno(upload)
          • 音乐生成(generations)
          • 查询任务(feed)
      • 生成歌词
        • 获取歌词
        • 生成歌词
    • Luma视频接口
      • GoAmzAI格式
        • 付费版
          • 生成视频
          • 获取视频
        • 免费版
          • 生成视频
          • 获取视频
      • 官网原生格式(v2)
        • 提交生成视频任务
        • 查询单个任务
        • 扩展视频
        • 获取视频无水印链接
    • SD图像接口
      • SD3
        • Stable Image Ultra
        • Stable Image Core
        • Stable Diffusion 3
      • SDXL
        • Text-to-image
          POST
  • 帮助中心
    • 常见问题及解决办法
  1. SDXL

Text-to-image

POST
/sd/v1/generation/{engine_id}/text-to-image
SDXL & SD1.6
Generate an image from a text prompt.

Using SDXL 1.0#

Use stable-diffusion-xl-1024-v1-0 as the engine_id of your request and pass in height & width as one of the following combinations:
1024x1024
1152x896
896x1152
1216x832
1344x768
768x1344
1536x640
640x1536.

Using SD 1.6#

Pass in stable-diffusion-v1-6 as the engine_id of your request and ensure the height & width you pass in adhere to the following restrictions:
No dimension can be less than 320 pixels
No dimension can be greater than 1536 pixels

Using SD Beta#

Pass in stable-diffusion-xl-beta-v2-2-2 as the engine_id of your request and ensure the height & width you pass in adhere to the following restrictions:
dimensions must be between 128x128 and 512x896 (or 896x512)
only one dimension can be greater than 512, but not both
NOTE: Only Version 1 engines will work with this endpoint.

请求参数

Path 参数
engine_id
string 
必需
示例值:
stable-diffusion-v1-6
Header 参数
Accept
enum<string> 
可选
The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image.
枚举值:
application/jsonimage/png
默认值:
application/json
Organization
string 
可选
Allows for requests to be scoped to an organization other than the user's default. If not provided, the user's default organization will be used.
示例值:
org-123456
Stability-Client-ID
string 
可选
Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity.
示例值:
my-great-plugin
Stability-Client-Version
string 
可选
Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity.
示例值:
1.2.1
Body 参数application/json
Represents the optional parameters that can be passed to any generation request.
height
integer 
DiffuseImageHeight
可选
Height of the image to generate, in pixels, in an increment divisible by 64.
>= 128
默认值:
512
示例值:
512
倍数:
64
width
integer 
DiffuseImageWidth
可选
Width of the image to generate, in pixels, in an increment divisible by 64.
>= 128
默认值:
512
示例值:
512
倍数:
64
text_prompts
array[object (TextPrompt) {2}] 
TextPrompts
必需
An array of text prompts to use for generation.
Given a text prompt with the text A lighthouse on a cliff and a weight of 0.5, it would be represented as:
"text_prompts": [
  {
    "text": "A lighthouse on a cliff",
    "weight": 0.5
  }
]
>= 1 items
text
string 
必需
The prompt itself
<= 2000 字符
示例值:
A lighthouse on a cliff
weight
number <float>
可选
Weight of the prompt (use negative numbers for negative prompts)
示例值:
0.8167237
cfg_scale
number 
CfgScale
可选
How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)
>= 0<= 35
默认值:
7
示例值:
7
clip_guidance_preset
enum<string> 
ClipGuidancePreset
可选
枚举值:
FAST_BLUEFAST_GREENNONESIMPLESLOWSLOWERSLOWEST
默认值:
NONE
示例值:
FAST_BLUE
sampler
enum<string> 
Sampler
可选
Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you.
枚举值:
DDIMDDPMK_DPMPP_2MK_DPMPP_2S_ANCESTRALK_DPM_2K_DPM_2_ANCESTRALK_EULERK_EULER_ANCESTRALK_HEUNK_LMS
示例值:
K_DPM_2_ANCESTRAL
samples
integer 
Samples
可选
Number of images to generate
>= 1<= 10
默认值:
1
示例值:
1
seed
integer 
Seed
可选
Random noise seed (omit this option or use 0 for a random seed)
>= 0<= 4294967295
默认值:
0
示例值:
0
steps
integer 
Steps
可选
Number of diffusion steps to run.
>= 10<= 50
默认值:
30
示例值:
50
style_preset
enum<string> 
StylePreset
可选
Pass in a style preset to guide the image model towards a particular style.
This list of style presets is subject to change.
枚举值:
3d-modelanalog-filmanimecinematiccomic-bookdigital-artenhancefantasy-artisometricline-artlow-polymodeling-compoundneon-punkorigamiphotographicpixel-arttile-texture
extras
object 
Extras
可选
Extra parameters passed to the engine.
These parameters are used for in-development or experimental features and may change
without warning, so please use with caution.
示例
{
    "cfg_scale": 7,
    "height": 512,
    "width": 512,
    "sampler": "K_DPM_2_ANCESTRAL",
    "samples": 1,
    "steps": 30,
    "text_prompts": [
        {
            "text": "A lighthouse on a cliff",
            "weight": 1
        }
    ]
}

示例代码

Python
JavaScript
Go
Shell
Java
Swift
PHP
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Python
JavaScript
Go
Shell
curl --location --request POST '/sd/v1/generation/stable-diffusion-v1-6/text-to-image' \
--header 'Accept;' \
--header 'Organization: org-123456' \
--header 'Stability-Client-ID: my-great-plugin' \
--header 'Stability-Client-Version: 1.2.1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "cfg_scale": 7,
    "height": 512,
    "width": 512,
    "sampler": "K_DPM_2_ANCESTRAL",
    "samples": 1,
    "steps": 30,
    "text_prompts": [
        {
            "text": "A lighthouse on a cliff",
            "weight": 1
        }
    ]
}'

返回响应

🟢200Generation successful.
application/json
Body
An array of results from the generation request, where each image is a base64 encoded PNG.
artifacts
array[object (Image) {3}] 
可选
base64
string 
可选
Image encoded in base64
finishReason
enum<string> 
可选
枚举值:
CONTENT_FILTEREDERRORSUCCESS
示例值:
CONTENT_FILTERED
seed
number 
可选
The seed associated with this image
示例值:
1229191277
示例
{
    "artifacts": [
        [
            {
                "base64": "...very long string...",
                "finishReason": "SUCCESS",
                "seed": 1050625087
            },
            {
                "base64": "...very long string...",
                "finishReason": "CONTENT_FILTERED",
                "seed": 1229191277
            }
        ]
    ]
}
🟠400bad_request: one or more parameters were invalid.
🟠401unauthorized: API key missing or invalid
🟠403permission_denied: You lack the necessary permissions to perform this action
🟠404not_found: The requested resource/engine was not found
🔴500server_error: Some unexpected server error occurred
上一页
Stable Diffusion 3
下一页
常见问题及解决办法
Built with