Сохранение внешнего вида товара
Насколько сохраняются форма, пропорции, цвета, логотип и текст на упаковке.
руководство по модели
gpt-image-2-vip
Использует API OpenAI Images, поддерживает точные размеры, редактирование и три уровня качества.
Эти настройки сейчас доступны в 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. Если результата ещё нет, мы прямо об этом сообщаем и не показываем черновые данные.
Насколько сохраняются форма, пропорции, цвета, логотип и текст на упаковке.
Сохраняются ли объект и его контуры при замене только запрошенного фона и нет ли лишних изменений.