Skip to content

flux 绘图模型

其他语言 可通过 curl 实例 用 类似 dall-e-3 的 api 接口

curl 实例

shell
curl  https://api.openai-hk.com/v1/images/generations \
  -H 'Authorization: Bearer hk-替换为你的key' \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux",
    "prompt": "a white siamese cat",
    "n": 1,
    "size": "1024x1024"
  }'
curl  https://api.openai-hk.com/v1/images/generations \
  -H 'Authorization: Bearer hk-替换为你的key' \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux",
    "prompt": "a white siamese cat",
    "n": 1,
    "size": "1024x1024"
  }'

在线测试

注意 1.访问 https://flux.ddaiai.com (如果被墙了,换下二级域名前缀 suibian)


2.如果发现被墙了 可以自己换地址 https://suibian.ddaiai.comsuibian 换其他的 如 https://2024.ddaiai.com 都能访问

设置

然后在下图相应的地方设置
OpenAi接口地址:https://api.openai-hk.com
OpenAi API KEY: hk-你的apiKey
然后在下图相应的地方设置
OpenAi接口地址:https://api.openai-hk.com
OpenAi API KEY: hk-你的apiKey

cover

效果

输入框 提问对话 cover

Flux Api

  • 1.生成任务
  • 2.查询任务状态

生成任务

post https://api.openai-hk.com/vmodel/generate

shell
curl --request POST \
  --url https://api.openai-hk.com/vmodel/generate \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'Content-Type: application/json' \
  --data '{
    "model":"flux-schnell",
    "input": {
      "prompt": "空气",
      "num_outputs": 1,
      "aspect_ratio": "1:1",
      "output_format": "jpg",
      "output_quality": 80,
      "seed": 1900004
    }
  }'
curl --request POST \
  --url https://api.openai-hk.com/vmodel/generate \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'Content-Type: application/json' \
  --data '{
    "model":"flux-schnell",
    "input": {
      "prompt": "空气",
      "num_outputs": 1,
      "aspect_ratio": "1:1",
      "output_format": "jpg",
      "output_quality": 80,
      "seed": 1900004
    }
  }'

请求体关键字说明

字段类型说明
modelstring可选 flux flux-schnell flux-dev flux-pro
inputobject该模型下的参数
input.promptstring提示语
input.num_outputsnumber输出的张数 1-4
input.output_qualitynumber输出的质量 1-100
input.seednumber种子随机数
input.aspect_ratiostring比例 1:1 3:4 4:3 16:9 9:16 2:3 3:2

返回体 得到 id

json
{
  "id": "j3thn0r501rme0cm9xq9sy6xkc"
}
{
  "id": "j3thn0r501rme0cm9xq9sy6xkc"
}

查询任务状态

get https://api.openai-hk.com/vmodel/feed/{id}

json
{
  "id": "j3thn0r501rme0cm9xq9sy6xkc",
  "model": "flux-schnell",
  "input": {
    "aspect_ratio": "1:1",
    "num_outputs": 1,
    "output_format": "jpg",
    "output_quality": 80,
    "prompt": "空气",
    "seed": 1900004
  },
  "output": [
    "https://file.aigpai.com/xezq/g44ll27rzLKfdSUDv0UKeYcKYkbhNeUC6USpE3uRW0VMWSHoA/out-0.jpg"
  ],
  "status": "succeeded",
  "error": null
}
{
  "id": "j3thn0r501rme0cm9xq9sy6xkc",
  "model": "flux-schnell",
  "input": {
    "aspect_ratio": "1:1",
    "num_outputs": 1,
    "output_format": "jpg",
    "output_quality": 80,
    "prompt": "空气",
    "seed": 1900004
  },
  "output": [
    "https://file.aigpai.com/xezq/g44ll27rzLKfdSUDv0UKeYcKYkbhNeUC6USpE3uRW0VMWSHoA/out-0.jpg"
  ],
  "status": "succeeded",
  "error": null
}

关键字说明

字段类型说明
idstring
modelstring可选 flux flux-schnell flux-dev flux-pro
inputobject该模型下的参数
output[]string结果 url 地址
statusstring状态 starting processing succeeded failed
errorstring错误信息