API能力 OpenAI Image ModelsTTAPI整合openai的优秀图片模型,让你能以更为优惠的价格且方便的方式集成到你的服务。
Dalle3 生成图像
POST
https://api.ttapi.io/openai/v1/images/generations
根据文本提示使用DALL·E 3模型创建图像。DALL·E 3模型相对于市场上的其他模型而言对文字理解能力最强,你可以使用任何语言作为你的描述文案
Headers
Body
dall-e-3模型,描述词长度不能超过4000个字符
图像尺寸,可选范围:
1024x1024
1024x1792
1792x1024
注意:不同尺寸消耗ttapi quota不同
图片质量,可选范围:
standard - 标准
hd - 增强细节
请求示例
Python Node
Copy import requests
endpoint = "https://api.ttapi.io/openai/v1/images/generations"
headers = {
"TT-API-KEY": your_key
}
data = {
"prompt": "a cute cat",
"size": "1024x1024",
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
Copy const axios = require('axios');
let config = {
method: 'post',
url: 'https://api.ttapi.io/openai/v1/images/generations',
headers: {
'TT-API-KEY': 'your_key'
},
data : {
"prompt": "a cute cat",
"size": "1024x1024 "
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.status));
})
.catch(function (error) {
console.log(error);
});
返回示例
200 400
Copy {
"status": "SUCCESS",
"message": "success",
"data": {
"created": 1713577682,
"data": [
{
"revised_prompt": "A serene, domestic scene unfolding at dusk: a fluffy, long-haired tabby cat with piercing green eyes and distinctive black and white stripes curled up on a cozy, burgundy-colored velvet cushion. Around the cat is the warmth of a rustic country home, with wooden beams and a crackling fireplace. Light streams in through a large, arched window, painting the scene in the beautiful, ethereal light of golden hour.",
"url": "https://dalleprodaue.blob.core.windows.net/private/images/cbb4adae-b889-4adf-9b84-4cd6d72d74fc/generated_00.png?se=2024-04-21T01%3A48%3A14Z&sig=th9fuLXfJVtLUOWu%2BfkJk1aY8abDZTDe7aIWJ1QzLkY%3D&ske=2024-04-26T13%3A43%3A10Z&skoid=f4f58869-78fa-4857-8a87-4ce5ae4ba8c3&sks=b&skt=2024-04-19T13%3A43%3A10Z&sktid=33e01921-4d64-4f8c-a055-5bdaffd5e33d&skv=2020-10-02&sp=r&spr=https&sr=b&sv=2020-10-02"
}
]
}
}
Copy {
"status": "FAILED",
"message": "For the dall-e-3 model, \"size\" must be one of 1024x1024, 1792x1024, or 1024x1792.",
"data": null
}
GPT-4o 生成图像
POST
https://api.ttapi.io/openai/4o-image/generations
根据文本提示以及图片资源生成图片
Headers
Body
生成图片文字提示,因为目前为逆向模型,建议文案提示存在关键字:“画一张xxx”, “生成一张”,"draw a xxx" ,具体语言不限制,openai本身就支持多语言模型,中文支持也非常友好。
请求示例
Python Node
Copy import requests
endpoint = "https://api.ttapi.io/openai/4o-image/generations"
headers = {
"TT-API-KEY": your_key
}
data = {
"prompt": "画一张美女模特该衣服平面照拍摄照片,要求高像素,高逼真度,完美还原衣服所有细节,全身照专业姿势,身材性感,穿着潮流,面带微笑,欧美女性皮肤白皙",
"referImages": [
"https://cdn.ttapi.io/demo/2025-03-30/5d17dd5207daeeac86bcecd2d6405a0.jpg"
],
"hookUrl": "https://webhook-test.com/b129b43b6619f977b3227387fc290f7d"
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
Copy const axios = require('axios');
let config = {
method: 'post',
url: 'https://api.ttapi.io/openai/v1/4o-image/generations',
headers: {
'TT-API-KEY': 'your_key'
},
data : {
"prompt": "画一张美女模特该衣服平面照拍摄照片,要求高像素,高逼真度,完美还原衣服所有细节,全身照专业姿势,身材性感,穿着潮流,面带微笑,欧美女性皮肤白皙",
"referImages": [
"https://cdn.ttapi.io/demo/2025-03-30/5d17dd5207daeeac86bcecd2d6405a0.jpg"
],
"hookUrl": "https://webhook-test.com/b129b43b6619f977b3227387fc290f7d"
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.status));
})
.catch(function (error) {
console.log(error);
});
返回示例
200 400
Copy {
"status": "SUCCESS",
"message": "success",
"data": {
"jobId": "5ecc5080-b1d7-4b9f-8184-435e46ebb5cb"
}
}
Copy {
"status": "FAILED",
"message": "",
"data": null
}
GPT-4o生成结果查询
POST/GET
https://api.ttapi.io/openai/4o-image/fetch
获取GPT-4o生成任务结果,返回数据结构与hookUrl 中返回一致
Headers
Query / Body
请求示例
Python
Copy import requests
endpoint = "https://api.ttapi.io/openai/4o-image/fetch"
headers = {
"TT-API-KEY": your_key
}
data = {
"jobId": "5ecc5080-b1d7-4b9f-8184-435e46ebb5cb"
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
GPT-4o 异步响应JSON示例
ON_QUEUE SUCCESS FAILED
Copy {
"status": "ON_QUEUE",
"message": null,
"jobId": "0ccf0606-3f32-4090-85bd-1786e4593be5",
"data": {
"prompt": "画一张美女模特该衣服平面照拍摄照片,要求高像素,高逼真度,完美还原衣服所有细节,全身照专业姿势,身材性感,穿着潮流,面带微笑,欧美女性皮肤白皙",
"referImages": [
"https://cdn.ttapi.io/demo/2025-03-30/5d17dd5207daeeac86bcecd2d6405a0.jpg"
],
"imageUrl": null,
"quota": "2",
"finishTime": null,
"hookUrl": "https://webhook-test.com/b129b43b6619f977b3227387fc290f7d"
}
}
Copy {
"status": "SUCCESS",
"message": "success",
"jobId": "5ecc5080-b1d7-4b9f-8184-435e46ebb5cb",
"data": {
"prompt": "画一张美女模特该衣服平面照拍摄照片,要求高像素,高逼真度,完美还原衣服所有细节,全身照专业姿势,身材性感,穿着潮流,面带微笑,欧美女性皮肤白皙",
"referImages": [
"https://cdn.ttapi.io/demo/2025-03-30/5d17dd5207daeeac86bcecd2d6405a0.jpg"
],
"imageUrl": "https://cdnc.ttapi.io/2025-03-31/cd3f3ce5-06be-4b3a-9aed-014045ca1804.png",
"quota": "2",
"finishTime": "2025-03-31 04:25:33",
"hookUrl": "https://webhook-test.com/b129b43b6619f977b3227387fc290f7d"
}
}
Copy {
"status": "FAILED",
"message": "job failed",
"jobId": "b45fcf32-71a5-4df2-82c7-2e6300e32e29",
"data": {
"prompt": "画一张模特采光棚真实试衣场景,要求高像素,高逼真度,全身照专业姿势,中国模特美女,身材比例协调,面带微笑,皮肤白皙",
"referImages": [
"https://cdn.ttapi.io/demo/2025-03-30/5d17dd5207daeeac86bcecd2d6405a0.jpg"
],
"imageUrl": null,
"quota": "0",
"finishTime": "2025-03-31 04:10:21",
"hookUrl": "https://webhook-test.com/b129b43b6619f977b3227387fc290f7d"
}
}
GPT-4o 使用案例
应用场景/实践案例:
制作海报(我的垫图可能不太恰当,随便官网首页截了个图,具体实际使用需要调试)
提示词:结合图片,生成一张GPT-4o宣传海报,要求海报简洁大气,存在TTAPI的logo,科技风格主题
提示词:一张图详细解释马斯洛需求层次理论
提示词:画一张美女模特该衣服平面照拍摄照片,要求高像素,高逼真度,完美还原衣服所有细节,全身照专业姿势,身材性感,穿着潮流,面带微笑,欧美女性皮肤白皙
总结:
OpenAI推出的这个4o图片模型在现在的AI市场里来说显然是一个王炸模型,个人觉得文生图不是他最强的所在,最强的关键点在于改图 以及垫图生图
优点:
文本支持好。 基于OpenAI llm大模型语言理解能力强,文字支持友好不像其他图片模型的鬼画符 或者需要双引号+英文限制才会有概率 的在图片中贴上你想要的文本
垫图识图。 支持依据文案加识别就可以更改上传图片中的元素,或者依据上传图片生成你想要的场景图,这一点目前没有任何全品类的图片模型可以做到
不足:
人物刻画。 目前尝试,人物的刻画能力与Midjourney对比来说会差一些,比如要求生成的任务客户到汗珠,皮肤纹理,发丝等等。
尺寸控制。 目前由于官方还未给出api,整体图片的尺寸很难通过提示词进行精准的控制
细节把控。 目前需要高精度的使用场景,很难做到细节的刻画与把控