Want to translate file using openai API

I have a file that I am trying to translate from one language to another. I do not see any edit file instructions in the guide. I have tried many ways to do this suggested by chat gpt but none have worked. Does anyone know how to do this in windows cmd prompt? Is it even possible?

Welcome to the community!

Depending on how big the file is, you’ll probably have to do it piece by piece.

There used to be edit and insert modes, but they’ve been scrapped since. https://openai.com/index/gpt-3-edit-insert/ (but they likely didn’t do what you’d hope they do anyways)

Of course you can do it with the command prompt: look for the curl commands in the docs https://platform.openai.com/docs/guides/text-generation/chat-completions-api, and let chatgpt translate them to cmd or powershell for you if necessary.

Hello, thank you so much for the quick reply! I have gotten the chat in the cmd to work but I cannot figure out a way to upload and edit a file. I have found code in the link that you provided that helps split the file etc. What I need is to upload a file and be able to input an instruction that tells the AI to translate my text. I am starting to feel like this is not possible because I have not found any information regarding the topic. If there is any way that you can help me further, please feel free to do so. Again, thank you so much for your reply.

curl -X POST
-H “Authorization: Bearer YOUR_API_KEY”
-H “Content-Type: application/json”
-d “{"prompt": "Translate the following text from Spanish to English:\n\n$(cat C:/User/Example.txt)", "max_tokens": 100}”
“https ://api.openai.com/v1/engines/davinci-codex/completions”

I have tried to use this in cmd but I know that davinci and davinci-codex has been depracated. Is there something else that I should be using?

You can try the Playground to get it working and see if you want to code it out or not…


1 Like

curl -o -h example.txt -H “Authorization: Bearer API-KEY” ht tps://api.openai.com/v1/files/fileID/content -o response.txt

I feel like I am missing something. I know that the code above can copy the contents of the example.txt to response.txt and I want it do do exactly that but change the language in the process. Is there no way to imput this prompt?

That endpoint is for retrieving files from OpenAI’s storage, not sending to a language model. It can only access files that are produced by code interpreter in Assistants or other results files. So you have the wrong idea there. The first -o parameter is wrong.

As mentioned before, there is no “use an AI to translate the entire contents of a file” to a different world language API endpoint.

That is within the realm of possible applications an API developer could produce and bill for the AI services, though, using multiple layers of intelligent document section splitting and using an instructed AI to perform piecemeal tasks that can be re-assembled.