Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2023 18:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
An openai API example of using the DaVinci engine for language translation
const axios = require('axios');
const API_KEY = 'your_api_key_here';
const API_URL = '';
async function translateText(text, targetLanguage) {
const response = await`${API_URL}engines/davinci/translate`, {
target_language: targetLanguage,
}, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${API_KEY}`,
const translatedText =[0].text;
translateText('All the world is crazy', 'es');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment