查询异步图片生成任务
curl --request GET \
--url https://kaienapi.com/v1/images/generations/jobs/{job_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/v1/images/generations/jobs/{job_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kaienapi.com/v1/images/generations/jobs/{job_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/images/generations/jobs/{job_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "imgtask-...",
"object": "image.edit.job",
"status": "queued",
"created": 123,
"updated": 123,
"model": "<string>",
"started_at": 123,
"completed_at": 123,
"reference_urls": [
"<string>"
],
"data": [
{}
],
"error": {
"message": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}查询异步图片生成任务
查询异步图片生成任务。只能查询当前 API Key 所属用户创建的任务。任务成功后,data 字段与同步 Images 响应中的 data 数组保持一致。
轮询建议
前端或服务端轮询时,只在 succeeded 和 failed 终态停止。queued、running 表示任务仍在处理。建议前 30 秒每 2-3 秒查询一次,之后放慢到每 5-10 秒一次。网络请求临时失败时,等待下一轮继续查询,不要立即重复创建新任务。
GET
/
v1
/
images
/
generations
/
jobs
/
{job_id}
查询异步图片生成任务
curl --request GET \
--url https://kaienapi.com/v1/images/generations/jobs/{job_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/v1/images/generations/jobs/{job_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kaienapi.com/v1/images/generations/jobs/{job_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/images/generations/jobs/{job_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "imgtask-...",
"object": "image.edit.job",
"status": "queued",
"created": 123,
"updated": 123,
"model": "<string>",
"started_at": 123,
"completed_at": 123,
"reference_urls": [
"<string>"
],
"data": [
{}
],
"error": {
"message": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Authorizations
在请求头中传入:Authorization: Bearer sk-...
Path Parameters
创建任务返回的任务 ID。
Response
任务状态和结果
Example:
"imgtask-..."
Example:
"image.edit.job"
Available options:
queued, running, succeeded, failed Unix 秒级时间戳。
Unix 秒级时间戳。
任务成功后返回图片结果,结构与 Images 响应 data 数组一致。
Show child attributes
Show child attributes