AI 服务/图像生成
异步生成图像
POST
/
api
/
ai
/
image
/
generate
/
async
异步生成图像
curl --request POST \
--url https://aitoearn.cn/api/ai/image/generate/async \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"prompt": "A cute orange cat sitting by a window, soft natural light",
"model": "gpt-image-2"
}
'import requests
url = "https://aitoearn.cn/api/ai/image/generate/async"
payload = {
"prompt": "A cute orange cat sitting by a window, soft natural light",
"model": "gpt-image-2"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'A cute orange cat sitting by a window, soft natural light',
model: 'gpt-image-2'
})
};
fetch('https://aitoearn.cn/api/ai/image/generate/async', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aitoearn.cn/api/ai/image/generate/async"
payload := strings.NewReader("{\n \"prompt\": \"A cute orange cat sitting by a window, soft natural light\",\n \"model\": \"gpt-image-2\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 0,
"message": "请求成功",
"data": {
"logId": "string",
"status": "generating"
}
}授权
需要从 AiToEarn 获取 API Key。点击前往「API Key 获取教程」。
请求体
application/json
图片描述提示
Required string length:
1 - 4000示例:
"A cute orange cat sitting by a window, soft natural light"
返回格式
可用选项:
url, b64_json 示例:
"url"
最后修改于 2026年9月29日
⌘I
异步生成图像
curl --request POST \
--url https://aitoearn.cn/api/ai/image/generate/async \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"prompt": "A cute orange cat sitting by a window, soft natural light",
"model": "gpt-image-2"
}
'import requests
url = "https://aitoearn.cn/api/ai/image/generate/async"
payload = {
"prompt": "A cute orange cat sitting by a window, soft natural light",
"model": "gpt-image-2"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'A cute orange cat sitting by a window, soft natural light',
model: 'gpt-image-2'
})
};
fetch('https://aitoearn.cn/api/ai/image/generate/async', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aitoearn.cn/api/ai/image/generate/async"
payload := strings.NewReader("{\n \"prompt\": \"A cute orange cat sitting by a window, soft natural light\",\n \"model\": \"gpt-image-2\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 0,
"message": "请求成功",
"data": {
"logId": "string",
"status": "generating"
}
}
