ChatPlus API
  1. ChatPlus API
ChatPlus API
  • 发送测试请求
  • HTTP状态码含义
  • ChatPlus API
    • 文字对话聊天
      POST
    • 文字转换语音
      POST
    • 语音转换文字
      POST
    • 语音翻译英文
      POST
    • 文字转换图片
      POST
    • 图片内容识别
      POST
    • gpt-4逆向画图
      POST
    • 谷歌gemini-pro
      POST
    • SunoAI音乐生成
      POST
    • Midjourney绘图
      POST
    • Midjourney查询
      POST
  1. ChatPlus API

文字转换图片

POST
/v1/images/generations
根据提示信息模型将生成新图像。
支持的模型:dall-e-2、dall-e-3

请求参数

Header 参数
Content-Type
string 
必需
在HTTP的请求Header中添加参数Content-Type POST请求主体类型为application/json
示例值:
application/json
Authorization
string 
必需
在HTTP的请求Header中添加参数Authorization,其值为在Bearer之后拼接以sk-开头的令牌API KEY的值。
示例值:
Bearer {{API_KEY}}
Body 参数application/json
model
string 
必需
要使用的模型的名称目前仅支持 dall-e-2、dall-e-3。
prompt
string 
必需
所需图像的文本描述。最大长度为 1000 个字符。
n
integer 
必需
要生成的图像数。必须介于 1 和 10 之间。
size
string 
必需
生成图像的大小。必须是 256x256 、 512x512 或 1024x1024 之一。
response_format
string 
必需
生成的图像返回的格式。必须是 url 或 b64_json 之一。
示例
{
  "model": "dall-e-3",
  "prompt": "puppy dog, catching butterflies, garden",
  "n": 1,
  "size": "1024x1024",
  "response_format": "url"
}

示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://chatplusapi.cn/v1/images/generations' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "dall-e-3",
  "prompt": "puppy dog, catching butterflies, garden",
  "n": 1,
  "size": "1024x1024",
  "response_format": "url"
}'

返回响应

🟢200成功
application/json
Body
created
integer 
必需
data
array [object {2}] 
必需
revised_prompt
string 
必需
url
string 
必需
示例
{
  "created": 1715096616,
  "data": [
    {
      "revised_prompt": "A playful puppy dog in a lush garden, actively leaping towards colorful butterflies fluttering around. The scene captures the puppy in mid-jump, with its eyes fixed on a butterfly. The garden is vibrant with various flowers like roses and daisies, and the sun casts soft shadows on the green grass. The atmosphere is cheerful and lively, embodying a warm, sunny day.",
      "url": "https://filesystem.site/cdn/20240507/hI9c5Bt2skBMyiuFgacvQZ9rQDYU2f.webp"
    }
  ]
}
🟠403失败
上一页
语音翻译英文
下一页
图片内容识别
Built with