🟢DALL·E 3

TTAPI整合dalle3图片模型,让你能以更为优惠的价格且方便的方式集成到你的服务。

Dalle3 生成图像

POST https://api.ttapi.io/openai/v1/images/generations

根据文本提示使用DALL·E 3模型创建图像。DALL·E 3模型相对于市场上的其他模型而言对文字理解能力最强,你可以使用任何语言作为你的描述文案

Headers

NameValue

Content-Type

application/json

TT-API-KEY

用于请求授权 TT-API 的API密钥

Body

参数类型是否必须描述

prompt

string

dall-e-3模型,描述词长度不能超过4000个字符

size

string

图像尺寸,可选范围:

1024x1024

1024x1792

1792x1024 注意:不同尺寸消耗ttapi quota不同

model

string

固定值:dall-e-3

n

integer

生成图像数量,固定值:1

quality

string

图片质量,可选范围: standard - 标准 hd - 增强细节

注意:dalle3接口的任务结果是同步返回的并不需要异步回调或者再次去查询该任务结果,接口响应时间一般在3-15s中间,时效同步根据OpenAI官方。

请求示例

import requests

endpoint = "https://api.ttapi.io/openai/v1/images/generations"

headers = {
    "TT-API-KEY": your_key
}

data = {
    "prompt": "a cute cat",
    "model": "1024x1024",
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())

返回示例

Dalle3 返回图片存在有效期限制,使用请自行转存图片

{
    "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"
            }
        ]
    }
}

Last updated