Skip to content

flux Image Generation Model

Other languages can use a curl example with an API interface similar to dall-e-3

curl Example

shell
curl  https://api.openai-hk.com/v1/images/generations \
  -H 'Authorization: Bearer hk-replace-with-your-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-replace-with-your-key' \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux",
    "prompt": "a white siamese cat",
    "n": 1,
    "size": "1024x1024"
  }'

Online Test

Note 1. Visit https://flux.ddaiai.com (if blocked, try changing the subdomain prefix to suibian)


2. If it is blocked, you can change the address yourself: https://suibian.ddaiai.com — replace suibian with something else, e.g. https://2024.ddaiai.com, all of these work

Setup

Then configure the following fields as shown in the image below:
OpenAI API endpoint: https://api.openai-hk.com
OpenAI API KEY: hk-your-apiKey
Then configure the following fields as shown in the image below:
OpenAI API endpoint: https://api.openai-hk.com
OpenAI API KEY: hk-your-apiKey

cover

Result

Enter your prompt in the input box cover

flux-kontext

  • Attach an image
  • Enter a prompt in the input box describing the modifications to make to the image
  • model can be flux-kontext-max or flux-kontext-pro
shell
curl -X POST "https://api.openai-hk.com/v1/images/edits" \
  -H "Authorization: Bearer hk-replace-with-your-key" \
  -F "model=flux-kontext-pro" \
  -F "image[]=@body-lotion.png" \
  -F 'prompt=Generate a photorealistic image of a gift basket on a white background labeled "Relax & Unwind" with a ribbon and handwriting-like font, containing all the items in the reference pictures'
curl -X POST "https://api.openai-hk.com/v1/images/edits" \
  -H "Authorization: Bearer hk-replace-with-your-key" \
  -F "model=flux-kontext-pro" \
  -F "image[]=@body-lotion.png" \
  -F 'prompt=Generate a photorealistic image of a gift basket on a white background labeled "Relax & Unwind" with a ribbon and handwriting-like font, containing all the items in the reference pictures'
  • cover

Flux Api

    1. Create a task
    1. Query task status

Create a Task

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
    }
  }'

Request body field descriptions

FieldTypeDescription
modelstringOptions: flux flux-schnell flux-dev flux-pro
inputobjectParameters for this model
input.promptstringPrompt text
input.num_outputsnumberNumber of images to output, 1-4
input.output_qualitynumberOutput quality, 1-100
input.seednumberRandom seed
input.aspect_ratiostringAspect ratio: 1:1 3:4 4:3 16:9 9:16 2:3 3:2

Response body — returns an id

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

Query Task Status

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
}

Field descriptions

FieldTypeDescription
idstring
modelstringOptions: flux flux-schnell flux-dev flux-pro
inputobjectParameters for this model
output[]stringResult URL(s)
statusstringStatus: starting processing succeeded failed
errorstringError message