Skip to content

CreateEditImage method upload file report Supported file formats are 'image/png' #967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
XuruiPro opened this issue Apr 17, 2025 · 0 comments · May be fixed by #979
Open

CreateEditImage method upload file report Supported file formats are 'image/png' #967

XuruiPro opened this issue Apr 17, 2025 · 0 comments · May be fixed by #979
Labels
bug Something isn't working

Comments

@XuruiPro
Copy link

Your issue may already be reported!
Please search on the issue tracker before creating one.

Describe the bug
CreateEditImage method upload file report Supported file formats are 'image/png'

To Reproduce

config := openai.DefaultConfig("token")
config.HTTPClient = &http.Client{}
c := openai.NewClientWithConfig(config)
f4, _ := os.Open("./4.png")
defer f4.Close()
ctx := context.Background()
reqUrl := openai.ImageEditRequest{
	Image:          f4,
	Prompt:         "添加一只红色的鸭子",
	Model:          openai.CreateImageModelDallE2,
	Size:           openai.CreateImageSize512x512,
	ResponseFormat: openai.CreateImageResponseFormatURL,
	N:              1,
}
respUrl, err := c.CreateEditImage(ctx, reqUrl)
if err != nil {
	fmt.Printf("Image creation error: %v\n", err)
	return
}
fmt.Println(respUrl.Data[0].URL)

Expected behavior
Print out the URL address

Screenshots/Logs
Invalid file 'image': unsupported mimetype ('application/octet-stream'). Supported file formats are 'image/png'.

Environment (please complete the following information):

  • go-openai version: [e.g. v1.38.1]
  • Go version: [e.g. 1.20]
  • OpenAI API version: [e.g. v1]
  • OS: [e.g. Windows 10]

Additional context
Add any other context about the problem here.

@XuruiPro XuruiPro added the bug Something isn't working label Apr 17, 2025
@Static-Flow Static-Flow linked a pull request Apr 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant