Модель генерации изображений flux
Другие языки могут использовать пример curl с API-интерфейсом, аналогичным dall-e-3
Пример curl
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"
}'Онлайн-тестирование
Примечание 1. Посетите https://flux.ddaiai.com (если заблокировано, попробуйте изменить префикс поддомена на suibian)
2. Если заблокировано, вы можете изменить адрес самостоятельно: https://suibian.ddaiai.com — замените suibian на что-то другое, например https://2024.ddaiai.com, все они работают
Настройка
Затем настройте следующие поля, как показано на изображении ниже:
Конечная точка OpenAI API: https://api.openai-hk.com
Ключ OpenAI API: hk-your-apiKeyЗатем настройте следующие поля, как показано на изображении ниже:
Конечная точка OpenAI API: https://api.openai-hk.com
Ключ OpenAI API: hk-your-apiKey
Результат
Введите свой запрос в поле ввода
flux-kontext
- Прикрепите изображение
- Введите запрос в поле ввода, описывающий изменения, которые нужно внести в изображение
modelможет бытьflux-kontext-maxили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'Flux Api
- Создать задачу
- Запросить статус задачи
Создание задачи
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
}
}'Описание полей тела запроса
| Поле | Тип | Описание |
|---|---|---|
| model | string | Варианты: flux flux-schnell flux-dev flux-pro |
| input | object | Параметры для этой модели |
| input.prompt | string | Текст запроса |
| input.num_outputs | number | Количество выходных изображений, 1-4 |
| input.output_quality | number | Качество вывода, 1-100 |
| input.seed | number | Случайное начальное значение |
| input.aspect_ratio | string | Соотношение сторон: 1:1 3:4 4:3 16:9 9:16 2:3 3:2 |
Тело ответа — возвращает id
json
{
"id": "j3thn0r501rme0cm9xq9sy6xkc"
}{
"id": "j3thn0r501rme0cm9xq9sy6xkc"
}Запрос статуса задачи
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
}Описание полей
| Поле | Тип | Описание |
|---|---|---|
| id | string | |
| model | string | Варианты: flux flux-schnell flux-dev flux-pro |
| input | object | Параметры для этой модели |
| output | []string | URL результата(ов) |
| status | string | Статус: starting processing succeeded failed |
| error | string | Сообщение об ошибке |
OpenAi-HK
