- 前言(必读)
- OpenAI官方SDK使用教程
- 批量请求示例
- 聊天模型(Chat)
- 内容审查
- 向量嵌入
- 图片处理
- 音频模型(Audio)
- 绘画模型(Painting)
- MidJourney
- Dalle
- Grok
- Flux
- Ideogram
- stable-diffusion
- 视频模型(Video)
- 音乐创作(suno)
- 文档处理
- 3D模型
- 更多接口开发中...
- 查询令牌用量GET
- 查询令牌限额GET
图像生成
POST
/v1/images/generations
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Body 参数application/json
object {0}
示例
{
"model": "grok-2-image-1212",
"prompt": "一幅详细的图像描绘了一个广阔的石器时代城市,城市中高耸的摩天大楼由巨石和骨头构成。这里热闹非凡,各种性别和种族的人们共同展现出原始人和原始女性的统一外貌。他们身穿商务服装,与史前背景形成鲜明对比。化石化的塔楼点缀着石质天际线,而人们则保留着原始的设计,身上披着毛皮,搭配现代的西装和领带。形成了现代生活与史前时代的美丽融合。",
"n": 1
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1/images/generations' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "grok-2-image-1212",
"prompt": "一幅详细的图像描绘了一个广阔的石器时代城市,城市中高耸的摩天大楼由巨石和骨头构成。这里热闹非凡,各种性别和种族的人们共同展现出原始人和原始女性的统一外貌。他们身穿商务服装,与史前背景形成鲜明对比。化石化的塔楼点缀着石质天际线,而人们则保留着原始的设计,身上披着毛皮,搭配现代的西装和领带。形成了现代生活与史前时代的美丽融合。",
"n": 1
}'
返回响应
🟢200成功
application/json
Body
data
array [object {2}]
必需
url
string
可选
revised_prompt
string
可选
示例
{
"data": [
{
"url": "https://imgen.x.ai/xai-imgen/xai-tmp-imgen-11b443c1-3780-4690-849a-51430eecc0a9.jpeg",
"revised_prompt": "A high-resolution photograph of a bustling prehistoric city during the day, featuring towering skyscrapers made of large stones and bones. The main focus is on a group of people dressed in a mix of modern business attire and animal skins, interacting in the foreground. The central building, a grand stone and bone structure, stands prominently in the background. The scene is set under a clear sky, with the cityscape extending into the distance, showing more of the unique architecture without distracting elements. The overall composition emphasizes the harmonious blend of ancient and modern elements, with a focus on the people and their unique attire."
}
]
}