Skip to content
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

Invalid file for Batch API. Must be utf-8 encoded #19

Open
lollolman opened this issue Jun 13, 2024 · 2 comments
Open

Invalid file for Batch API. Must be utf-8 encoded #19

lollolman opened this issue Jun 13, 2024 · 2 comments

Comments

@lollolman
Copy link

lollolman commented Jun 13, 2024

When I try to use Add-OpeAIFile with the purpuse "batch" like this for example:

$upload = Add-OpenAIFile -File $file.FullName -Purpose "batch"

I receive this error:

Invoke-OpenAIAPIRequest: C:\Program Files\WindowsPowerShell\Modules\PSOpenAI\3.14.0\Public\Files\Add-OpenAIFile.ps1:95:21
Line |
  95 |          $Response = Invoke-OpenAIAPIRequest @params
     |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | OpenAI API returned an 400 (Bad Request) Error: Invalid file for Batch API. Must be utf-8 encoded

Any suggestions?
Many thanks!

L.

@mkht
Copy link
Owner

mkht commented Jun 14, 2024

Make sure the file you are about to upload is encoded in UTF-8.
If you try to upload a file saved in a different encoding, such as UTF-16 or UTF-7, you will receive that error.

@potatoqualitee
Copy link
Contributor

In my own wrappers, I convert to UTF-8 before uploading and it takes care of this restriction by OpenAI.

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

No branches or pull requests

3 participants