Kling image generation
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://models.phanedge.cloud/kling/v1/images/generations"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://models.phanedge.cloud/kling/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.phanedge.cloud/kling/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.phanedge.cloud/kling/v1/images/generations"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://models.phanedge.cloud/kling/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.phanedge.cloud/kling/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}图像生成
图像生成
接口与可灵官网一致;支持文生图、图生图、角色/人脸参考
POST
/
kling
/
v1
/
images
/
generations
Kling image generation
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://models.phanedge.cloud/kling/v1/images/generations"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://models.phanedge.cloud/kling/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.phanedge.cloud/kling/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.phanedge.cloud/kling/v1/images/generations"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://models.phanedge.cloud/kling/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.phanedge.cloud/kling/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}- 路径
POST /kling/v1/images/generations - 与官网一致:本页所有请求体、字段命名与返回结构与可灵官网保持一致
- 字段详解:请参考官网权威文档
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model_name | string | 否 | 模型名称,默认 kling-v1。可选:kling-v1、kling-v1-5、kling-v2、kling-v2-new、kling-v2-1 |
prompt | string | 是 | 正向文本提示词 |
negative_prompt | string | 否 | 负向文本提示词(图生图场景不支持) |
image | string | 否 | 参考图像 URL 或 Base64 |
image_reference | string | 否 | 图片参考类型:subject(角色特征)、face(人物长相),仅 kling-v1-5 支持 |
image_fidelity | number | 否 | 图片参考强度 [0, 1] |
human_fidelity | number | 否 | 面部参考强度 [0, 1] |
resolution | string | 否 | 清晰度:1k(标清)、2k(高清),默认 1k |
n | int | 否 | 生成图片数量 [1, 9],默认 1 |
aspect_ratio | string | 否 | 纵横比:16:9、9:16、1:1、4:3、3:4、3:2、2:3、21:9,默认 16:9 |
watermark_info | object | 否 | 是否生成含水印结果 |
callback_url | string | 否 | 回调通知地址 |
external_task_id | string | 否 | 自定义任务ID |
注意:使用kling-v1-5且image参数不为空时,image_reference参数必填。非kling-v1-5模型不支持image_reference。 补充约束:prompt长度 ≤ 2500;图生图场景(image非空)不支持negative_prompt。
场景一:文生图
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model_name": "kling-v1",
"prompt": "A beautiful sunset over the ocean, vibrant colors, high detail",
"resolution": "2k",
"n": 1,
"aspect_ratio": "16:9"
}'
场景二:角色特征参考
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model_name": "kling-v1-5",
"prompt": "The character holding a magic wand in a fantasy forest",
"image": "https://example.com/character-reference.jpg",
"image_reference": "subject",
"image_fidelity": 0.8,
"resolution": "2k",
"aspect_ratio": "3:4"
}'
场景三:人脸参考
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model_name": "kling-v1-5",
"prompt": "A professional headshot portrait, business attire, studio lighting",
"image": "https://example.com/face-photo.jpg",
"image_reference": "face",
"human_fidelity": 0.9,
"resolution": "2k",
"aspect_ratio": "1:1"
}'
场景四:批量生成
curl --request POST \
--url https://models.phanedge.cloud/kling/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model_name": "kling-v2",
"prompt": "Abstract colorful artwork, modern style",
"n": 4,
"resolution": "1k",
"aspect_ratio": "1:1"
}'
{
"code": 0,
"message": "success",
"request_id": "req_1735558800_img123",
"data": {
"task_id": "task_01JGHP...",
"task_status": "submitted",
"created_at": 1735558800000,
"updated_at": 1735558800000
}
}
{
"code": 0,
"message": "success",
"data": {
"task_id": "task_01JGHP...",
"task_status": "succeed",
"task_result": {
"images": [
{"index": 0, "url": "https://..."},
{"index": 1, "url": "https://..."}
]
}
}
}
Authorizations
Authorization: Bearer
Body
application/json
The body is of type object.
Response
200 - application/json
OK
The response is of type object.

