Skip to content

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

Open
@XuruiPro

Description

@XuruiPro

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.

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