Skip to content

hatch-pet: send application/json for text-only image generation requests#387

Open
gdorta wants to merge 1 commit into
openai:mainfrom
gdorta:fix/hatch-pet-text-only-generation
Open

hatch-pet: send application/json for text-only image generation requests#387
gdorta wants to merge 1 commit into
openai:mainfrom
gdorta:fix/hatch-pet-text-only-generation

Conversation

@gdorta
Copy link
Copy Markdown

@gdorta gdorta commented May 3, 2026

Bug

generate_pet_images.py sends multipart/form-data for text-only image generation requests. The OpenAI Images API rejects this on /v1/images/generations, which expects application/json. Result: text-only pet generation fails with unsupported multipart/form-data; endpoint expected application/json.

Reference-backed pets use /v1/images/edits, where multipart upload remains the correct path.

Fix

Build a JSON payload for text-only generation requests:

  • No reference -> POST /v1/images/generations with application/json
  • Reference -> POST /v1/images/edits with multipart upload fields, unchanged

Added an inline comment documenting the API contract.

Verification

Tested locally against copied prepared run directories:

  • Text-only base request succeeded with the fix.
  • Reference-backed base request succeeded with no regression.
  • Both outputs decoded as valid 1024x1024 PNGs.

Context

Encountered while building The Hatchery, a marketplace for Codex pets. Happy to iterate on the fix shape if there is a preferred convention.

generate_pet_images.py sent multipart/form-data for text-only image generation requests. The OpenAI Images API requires application/json for /v1/images/generations, while reference-backed image edits use multipart/form-data for /v1/images/edits.

Build a JSON payload for /generations requests and keep the existing multipart upload path for /edits. Add an inline comment documenting the API contract so the next reader does not reintroduce the mismatch.

Tested locally with a text-only base request and a reference-backed base request.
@gdorta gdorta requested a review from a team May 3, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant