Home

Awesome

OpenAI Automatic Translation

Use ChatGPT language models to automatically translate your content through Directus Flows!

Details

Requirements

How to use this Operation

  1. Add this extension into the project's extensions/operations folder
  2. Update your project's environment file with the following:
OPENAI_API_KEY="sk-XXXXXXXXXXXXXXXXXXX"
OPENAI_RATE_LIMIT="21000"

The rate limit is in ms. By default ChatGPT limits free trial accounts to 3 API calls per minute. Setting this to 21000 (21 seconds) ensures this limit is not reached.

  1. Start/Restart Directus
  2. Create a new Flow with an Event trigger for your collection. I recommend using the item.create event
  3. Add a new operation to your flow and choose OpanAI Auto Translate
  4. Set the item ID to {{$trigger.key}} and collection to {{$trigger.collection}}
  5. Choose the translations collection and languages collection from the list, then Save and close the Flow
  6. Create a new item and wait a couple minutes (depending on your rate limit)

Screenshots

This is how it appears in the list of Operations when adding to a Flow. Operation in the list

Flow using this Operation Create Flows

Example of the operation settings Operation Settings

Creating a new item in the collection New Item

After a few minutes, opened the item and clicked the language dropdown. The progress bar for each translation is complete. Translation Progress

Example of the Russian translation performed by ChatGPT 3.5 Turbo Russian Translation