获取 Midjourney 图片资源
curl --request GET \
--url https://kaienapi.com/mj/image/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/mj/image/{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/mj/image/{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/mj/image/{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))
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}获取 Midjourney 图片资源
获取 Midjourney 图片资源。
请求格式
传入任务或图片资源 ID。响应体是图片文件本体,不是 JSON。
读取结果
浏览器端转成 Blob 展示或下载;服务端保存到对象存储。根据响应的 Content-Type 和文件名设置扩展名。
错误定位
- 404:确认任务已经完成,并且传入的是可下载的图片 ID。
- 浏览器无法预览:检查响应类型和 Blob URL 创建方式。
- 需要长期访问:下载后保存到对象存储。
GET
/
mj
/
image
/
{id}
获取 Midjourney 图片资源
curl --request GET \
--url https://kaienapi.com/mj/image/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://kaienapi.com/mj/image/{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/mj/image/{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/mj/image/{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))
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}