公開テスト結果なし
商品デザインの保持
形状、比率、色、ロゴ、パッケージ上の文字に意図しない変化がないかを確認します。
モデルガイド
gpt-image-2-vip
OpenAI Images API を使用し、正確なサイズ、画像編集、3段階の品質設定に対応します。
以下は YingTu で現在利用できる設定です。
A minimal coffee poster with the exact headline “COFFEE MADE SIMPLE”, high contrast type, warm natural light, clean commercial layout.
A clean e-commerce banner with a centered product, generous copy space, neutral background, and precise visual hierarchy.
A polished onboarding illustration with a simple interface motif, restrained colors, crisp shapes, and generous negative space.
以下は画像スタジオで現在利用できる設定です。
画像スタジオと同じリクエスト形式を使った例です。
import base64
import mimetypes
import os
import sys
import requests
API_KEY = os.environ.get("LAOZHANG_API_KEY")
if not API_KEY:
raise RuntimeError("Set the LAOZHANG_API_KEY environment variable before running this example.")
REQUEST_TIMEOUT_SECONDS = 500
headers = {"Authorization": f"Bearer {API_KEY}"}
def extension_for_mime(mime_type):
return {
"image/jpeg": "jpg",
"image/png": "png",
"image/webp": "webp",
"image/gif": "gif",
}.get(mime_type, "bin")
def decode_base64_image(value, fallback_mime="image/png"):
mime_type = fallback_mime
encoded = value
if value.startswith("data:"):
header, encoded = value.split(",", 1)
mime_type = header[5:].split(";", 1)[0] or fallback_mime
return base64.b64decode(encoded, validate=True), mime_type
def parse_json_response(response):
try:
result = response.json()
except ValueError as error:
print("API returned a non-JSON response.", file=sys.stderr)
raise SystemExit(1) from error
if not isinstance(result, dict):
print("API returned an unexpected JSON shape.", file=sys.stderr)
raise SystemExit(1)
return result
def extract_image(result):
if not isinstance(result, dict):
return None
images = result.get("data") or []
first_image = images[0] if images and isinstance(images[0], dict) else {}
encoded = first_image.get("b64_json")
if isinstance(encoded, str) and encoded:
return decode_base64_image(encoded)
image_url = first_image.get("url")
if isinstance(image_url, str) and image_url:
image_response = requests.get(image_url, timeout=REQUEST_TIMEOUT_SECONDS)
image_response.raise_for_status()
mime_type = image_response.headers.get("Content-Type", "image/png").split(";", 1)[0]
return image_response.content, mime_type
return None
def save_result_image(result):
extracted = extract_image(result)
if not extracted:
keys = sorted(result.keys()) if isinstance(result, dict) else []
print(f"No image data in response. Top-level keys: {keys}", file=sys.stderr)
raise SystemExit(1)
image_bytes, mime_type = extracted
output_path = f"output.{extension_for_mime(mime_type)}"
with open(output_path, "wb") as output_file:
output_file.write(image_bytes)
print(f"Image saved: {output_path} ({mime_type})")
API_URL = "https://api2.laozhang.ai/v1/images/generations"
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-image-2-vip",
"prompt": "A minimal coffee poster with the exact headline “COFFEE MADE SIMPLE”, high contrast type, warm natural light, clean commercial layout.",
"size": "2048x2048",
"quality": "high"
}
try:
response = requests.post(
API_URL,
headers=headers,
json=payload,
timeout=REQUEST_TIMEOUT_SECONDS,
)
except requests.Timeout as error:
print(
"Request timed out after 500 seconds. The result status may be unknown; "
"check call and billing logs before retrying.",
file=sys.stderr,
)
raise SystemExit(1) from error
if response.status_code != 200:
print(f"API error {response.status_code}: {response.text}", file=sys.stderr)
raise SystemExit(1)
save_result_image(parse_json_response(response))
これらの画像には生成時のモデルとプロンプトが記録されていません。視覚例であり、モデルのテスト結果ではありません。



テスト記録
ここには、テスト条件と生成結果を確認できる形で公開した YingTu の記録だけを掲載します。未公開の記録は表示しません。
形状、比率、色、ロゴ、パッケージ上の文字に意図しない変化がないかを確認します。
被写体が保たれているか、輪郭が崩れていないか、指定した背景になっているかを確認します。