Краткий вывод

  • Use POST /v1/images/generations with model=gpt-image-2.
  • Supports prompt generation and reference_images URL inputs for guided generation.
  • Reference images must be URLs, so local files must be uploaded first instead of passing base64 directly.
  • The endpoint returns an async task id for later status polling.

Ключевые параметры

  • model | string | обяз. | gpt-image-2 | - | Use gpt-image-2 as the exact model id.
  • prompt | string | обяз. | - | - | Primary prompt for image generation or editing.
  • size | string | опц. | 1024x1024 | Use documented combinations with resolution | Output size constrained by documented resolution combinations.
  • resolution | string | опц. | 1024 | 1024 | 1536 | 2048 | Output resolution with documented size constraints.
  • reference_images | string[] | опц. | - | URL array | Reference image URL array. Local files must be uploaded first; no direct base64 references.
  • image_urls | string[] | опц. | - | URL array (compat field) | Compatibility field; prefer reference_images for new integrations.
  • response_format | string | опц. | url | url | b64_json | Response format; current Chinese docs recommend url.

Частые ошибки

  • 400 invalid_request_error: триггер=Missing required fields or invalid size-resolution combinations.; исправление=Validate model, prompt, size, resolution, and response_format against docs.; повтор=Retry only after correcting the payload.
  • 400 invalid_reference_images: триггер=Passing base64, local paths, or non-URL reference_images values.; исправление=Upload the image first and pass the resulting URL in reference_images.; повтор=Retry after fixing the reference image input.
  • 401 authentication_error: триггер=Missing Authorization header or invalid API key.; исправление=Verify bearer token format and key scope.; повтор=Retry after fixing authentication.
  • 429 rate_limit_exceeded: триггер=Request rate, concurrency, or current quota hits upstream rate limiting.; исправление=Apply exponential backoff first, then review request rate, concurrency, and quota usage.; повтор=Use 1s/2s/4s backoff with jitter; if it persists, reduce submission pressure.

Разбор модели

GPT-Image-2

Model ID: gpt-image-2

Вендор: OpenAIМодальности: ImageЦена: $0.0150 /requestОбновлено: 2026-05-02

GPT-Image-2 is an image generation model on ToAPIs using /v1/images/generations for text-to-image and reference-guided generation, aligned with ToAPIs docs.

Обзор модели

Quick Answer

  • Use POST /v1/images/generations with model=gpt-image-2.
  • Supports prompt generation and reference_images URL inputs for guided generation.
  • Reference images must be URLs, so local files must be uploaded first instead of passing base64 directly.
  • The endpoint returns an async task id for later status polling.

GPT-Image-2 Возможности модели

Ключевой блок

Ключевые возможности и практическая ценность

Text to image

Submit standard prompt-driven image generation tasks through the unified API.

Reference-guided generation

Pass image URLs through reference_images for style or subject guidance.

Async task workflow

The endpoint returns a task id for queueing and polling pipelines.

Как использовать API GPT-Image-2

  1. Prepare Authorization: Bearer <YOUR_API_KEY> and the main prompt.
  2. Upload local reference images first if reference URLs are needed.
  3. POST to /v1/images/generations with model=gpt-image-2 plus optional size, resolution, reference_images, and response_format.
  4. Poll task progress with the image task status API.
  5. Read final image URLs after the task completes.
GPT-Image-2

Когда использовать

  • When integrating a standard text-to-image workflow through the gateway.
  • When references are needed for style continuation or subject guidance.
  • When image generation must fit into async task orchestration.

Особенности работы API

  • The endpoint returns a task object before the final image is ready.
  • Poll queued, in_progress, completed, and failed states through the image task status API.
  • Reference workflows require reference_images URLs, so local files must be uploaded first.
  • size and resolution combinations must follow documented limits.
GPT-Image-2

Key Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstringYesgpt-image-2-Use gpt-image-2 as the exact model id.
promptstringYes--Primary prompt for image generation or editing.
sizestringNo1024x1024Use documented combinations with resolutionOutput size constrained by documented resolution combinations.
resolutionstringNo10241024 | 1536 | 2048Output resolution with documented size constraints.
reference_imagesstring[]No-URL arrayReference image URL array. Local files must be uploaded first; no direct base64 references.
image_urlsstring[]No-URL array (compat field)Compatibility field; prefer reference_images for new integrations.
response_formatstringNourlurl | b64_jsonResponse format; current Chinese docs recommend url.

Common Errors

400 invalid_request_error

Trigger: Missing required fields or invalid size-resolution combinations.

Fix: Validate model, prompt, size, resolution, and response_format against docs.

Retry: Retry only after correcting the payload.

400 invalid_reference_images

Trigger: Passing base64, local paths, or non-URL reference_images values.

Fix: Upload the image first and pass the resulting URL in reference_images.

Retry: Retry after fixing the reference image input.

401 authentication_error

Trigger: Missing Authorization header or invalid API key.

Fix: Verify bearer token format and key scope.

Retry: Retry after fixing authentication.

429 rate_limit_exceeded

Trigger: Request rate, concurrency, or current quota hits upstream rate limiting.

Fix: Apply exponential backoff first, then review request rate, concurrency, and quota usage.

Retry: Use 1s/2s/4s backoff with jitter; if it persists, reduce submission pressure.

GPT-Image-2

FAQ

How do I call gpt-image-2?

Call POST /v1/images/generations with model=gpt-image-2, prompt, and optional size, resolution, and reference_images.

Does gpt-image-2 support image-to-image?

Yes. Pass reference_images URLs to guide output style or subject consistency.

Why can’t I pass base64 reference images directly?

The current docs require reference_images to be URLs. Upload local files first and then pass the returned URLs.

How do I check status after the task id is returned?

Poll the image task status endpoint until the task is completed, then read the output image fields.

Ошибка у модели изображений или видео: invalid apitype: -1

Обычно это означает, что запрос отправлен не в тот endpoint. Модели изображений и видео обычно не используют chat endpoint. Вместо этого нужно отправлять HTTP-запрос на создание задачи по документации и затем опрашивать endpoint статуса задачи. Сначала проверьте фактический код запроса, URL и payload.

Задача на генерацию изображения или видео завершилась ошибкой, но списание произошло

Сначала попросите у пользователя лог задачи или скриншот и проверьте, есть ли там статистика входных или выходных токенов. Если учет токенов есть, запрос, скорее всего, был отправлен через chat endpoint, а не через правильный media workflow. Модели изображений и видео обычно работают как асинхронные HTTP task API: сначала отправляется задача, затем выполняется опрос по task id согласно документации.

Mode Notes

Text-to-Image Task with GPT-Image-2

Create GPT-Image-2 image generation tasks directly from prompts.

Mode Parameters

modelpromptsizeresolutionresponse_format

Best Scenarios

  • Standard image generation
  • Creative visuals
  • Async image workflows

Reference-guided Task with GPT-Image-2

Pass uploaded reference image URLs for guided generation outputs.

Mode Parameters

reference_imagesimage_urlspromptsizeresolution

Best Scenarios

  • Style continuation
  • Subject guidance
  • Image editing

Related APIs

Готовы начать?

Зарегистрируйтесь бесплатно и испытайте мощь корпоративного API-шлюза для ИИ

ToAPIs

Корпоративный шлюз AI API. Доступ к GPT-5, Claude, Gemini и 50+ моделям через единый API.

Компания

Правовая информация

© 2026 ToAPIs. Все права защищены.

Все системы работают