Skip to content

CreateEditImage with gpt-image-1 always returns missing_file_mimetype #1012

Open
@Icety

Description

@Icety

Describe the bug
When trying to use the gpt-image-1 model with the imageEdit feature to edit a local png, I always get the error:
missing_file_mimetype. I tried streaming, fetching as http and passing the body, but I always get the same error.

To Reproduce

file, _ := os.Open("./example.png")
		defer file.Close()

		resp, err = openai.NewClient(key).CreateEditImage(
			context.Background(),
			openai.ImageEditRequest{
				Image:          file,
				Model:          openai.CreateImageModelGptImage1,
				Prompt:         prompt,
				Quality:        openai.CreateImageQualityLow,
				N:              1,
				Size:           openai.CreateImageSize1024x1024,
				ResponseFormat: openai.CreateImageOutputFormatPNG,
			},
		)

Expected behavior
I expect an image to be created based on the provided example image.

Screenshots/Logs
Error code: missing_file_mimetype
Error message: Invalid file 'image': failed to determine mimetype. Ensure you are providing the file's mimetype as part of the 'Content-Type' header.

Environment:

  • go-openai version: 1.40.1
  • Go version: 1.22.4
  • OpenAI API version: v1
  • OS: Mac Sequoia

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions