Flux Kontext 画像生成/編集
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/flux-kontext \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a beautiful landscape with mountains",
"aspect_ratio": "16:9",
"enable_translation": true,
"input_image": "https://example.com/input.jpg",
"model": "flux-kontext-pro",
"output_format": "jpeg",
"prompt_upsampling": false,
"safety_tolerance": 2,
"upload_cn": false,
"watermark": ""
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/flux-kontext"
payload = {
"prompt": "a beautiful landscape with mountains",
"aspect_ratio": "16:9",
"enable_translation": True,
"input_image": "https://example.com/input.jpg",
"model": "flux-kontext-pro",
"output_format": "jpeg",
"prompt_upsampling": False,
"safety_tolerance": 2,
"upload_cn": False,
"watermark": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'a beautiful landscape with mountains',
aspect_ratio: '16:9',
enable_translation: true,
input_image: 'https://example.com/input.jpg',
model: 'flux-kontext-pro',
output_format: 'jpeg',
prompt_upsampling: false,
safety_tolerance: 2,
upload_cn: false,
watermark: ''
})
};
fetch('https://api.sinancode.com/v1/generate/k/flux-kontext', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sinancode.com/v1/generate/k/flux-kontext",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'a beautiful landscape with mountains',
'aspect_ratio' => '16:9',
'enable_translation' => true,
'input_image' => 'https://example.com/input.jpg',
'model' => 'flux-kontext-pro',
'output_format' => 'jpeg',
'prompt_upsampling' => false,
'safety_tolerance' => 2,
'upload_cn' => false,
'watermark' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sinancode.com/v1/generate/k/flux-kontext"
payload := strings.NewReader("{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sinancode.com/v1/generate/k/flux-kontext")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/flux-kontext")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}画像生成 - Flux
Flux Kontext
Flux Kontext モデルを使用した画像の生成または編集(非同期)
POST
/
generate
/
k
/
flux-kontext
Flux Kontext 画像生成/編集
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/flux-kontext \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a beautiful landscape with mountains",
"aspect_ratio": "16:9",
"enable_translation": true,
"input_image": "https://example.com/input.jpg",
"model": "flux-kontext-pro",
"output_format": "jpeg",
"prompt_upsampling": false,
"safety_tolerance": 2,
"upload_cn": false,
"watermark": ""
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/flux-kontext"
payload = {
"prompt": "a beautiful landscape with mountains",
"aspect_ratio": "16:9",
"enable_translation": True,
"input_image": "https://example.com/input.jpg",
"model": "flux-kontext-pro",
"output_format": "jpeg",
"prompt_upsampling": False,
"safety_tolerance": 2,
"upload_cn": False,
"watermark": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'a beautiful landscape with mountains',
aspect_ratio: '16:9',
enable_translation: true,
input_image: 'https://example.com/input.jpg',
model: 'flux-kontext-pro',
output_format: 'jpeg',
prompt_upsampling: false,
safety_tolerance: 2,
upload_cn: false,
watermark: ''
})
};
fetch('https://api.sinancode.com/v1/generate/k/flux-kontext', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sinancode.com/v1/generate/k/flux-kontext",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'a beautiful landscape with mountains',
'aspect_ratio' => '16:9',
'enable_translation' => true,
'input_image' => 'https://example.com/input.jpg',
'model' => 'flux-kontext-pro',
'output_format' => 'jpeg',
'prompt_upsampling' => false,
'safety_tolerance' => 2,
'upload_cn' => false,
'watermark' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sinancode.com/v1/generate/k/flux-kontext"
payload := strings.NewReader("{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sinancode.com/v1/generate/k/flux-kontext")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/flux-kontext")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"a beautiful landscape with mountains\",\n \"aspect_ratio\": \"16:9\",\n \"enable_translation\": true,\n \"input_image\": \"https://example.com/input.jpg\",\n \"model\": \"flux-kontext-pro\",\n \"output_format\": \"jpeg\",\n \"prompt_upsampling\": false,\n \"safety_tolerance\": 2,\n \"upload_cn\": false,\n \"watermark\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}Flux Kontext モデルを使用して画像を生成します。
主な特徴:
- 多言語サポート - 中国語プロンプトをサポートし、自動翻訳機能付き
- コンテキスト認識 - インテリジェントなコンテキスト理解
承認
API Tokenを使用して認証を行ってください
ボディ
application/json
タスクパラメータ
プロンプト(必須、英語をサポート)
Minimum string length:
1例:
"a beautiful landscape with mountains"
アスペクト比(オプション、デフォルト 16:9)
利用可能なオプション:
auto, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16 例:
"16:9"
自動翻訳を有効化(オプション、デフォルト true)
例:
true
入力画像URL(オプション、編集モードで使用)
例:
"https://example.com/input.jpg"
モデルバージョン(オプション、デフォルト flux-kontext-pro)
利用可能なオプション:
flux-kontext-pro, flux-kontext-max 例:
"flux-kontext-pro"
出力形式(オプション、デフォルト jpeg)
利用可能なオプション:
jpeg, png 例:
"jpeg"
プロンプト拡張を有効化(オプション、デフォルト false)
例:
false
安全性許容レベル(オプション、0-6、デフォルト2)
必須範囲:
0 <= x <= 6例:
2
中国本土サーバーを使用してアップロード(オプション)
例:
false
ウォーターマーク識別子(オプション)
例:
""
レスポンス
OK
タスクID
例:
"01234567-89ab-cdef-0123-456789abcdef"
⌘I