API: PaLM2 Translations with Custom Glossary


📖 To learn more, take a look at our complete API

📤 Example Request

  1. Generate an api key below👇

  2. Install node-fetch & add the GOOEY_API_KEY to your environment variables.
    Never store the api key in your code and don't use direcly in the browser.

$ npm install node-fetch
$ export GOOEY_API_KEY=sk-xxxx
  1. Use this sample code to call the API.
    If you encounter any issues, write to us at [email protected] and make sure to include the full code snippet and the error message.
import fetch from 'node-fetch';

const payload = {
  "input_prompt": "Remember this glossary of fixed translation terms. The columns represent language codes in BCP47 and the rows are the terms:\n{{ glossary }}\n\nPROMPT: Please use the glossary to translate the following text from en-US to da-DK.\n<Q>Hello, my name is Bob and I work at gooey.ai which is an awesome company that coincidentally also made this tool. I am made by goowy.\n<A>Hej, jeg hedder Bob, og jeg arbejder hos Gooey.AI, som er en fantastisk virksomhed, der tilf\u00e6ldigvis ogs\u00e5 lavede dette v\u00e6rkt\u00f8j. Jeg er lavet af Gooey.\nPROMPT: Please use the glossary to translate the following text from {{ source_language }} to {{ target_language }}.\n<Q>{{ text_to_translate }}\n<A>",
  "selected_models": [
    "palm2_chat"
  ]
};

async function gooeyAPI() {
  const response = await fetch("https://api.gooey.ai/v2/CompareLLM?example_id=a5vwv24t", {
    method: "POST",
    headers: {
      "Authorization": "bearer " + process.env["GOOEY_API_KEY"],
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });

  if (!response.ok) {
    throw new Error(response.status);
  }

  const result = await response.json();
  console.log(response.status, result);
}

gooeyAPI();
  1. Generate an api key below👇

  2. Install requests & add the GOOEY_API_KEY to your environment variables.
    Never store the api key in your code.

$ python3 -m pip install requests
$ export GOOEY_API_KEY=sk-xxxx
  1. Use this sample code to call the API.
    If you encounter any issues, write to us at [email protected] and make sure to include the full code snippet and the error message.
import os
import requests

payload = {
    "input_prompt": "Remember this glossary of fixed translation terms. The columns represent language codes in BCP47 and the rows are the terms:\n{{ glossary }}\n\nPROMPT: Please use the glossary to translate the following text from en-US to da-DK.\n<Q>Hello, my name is Bob and I work at gooey.ai which is an awesome company that coincidentally also made this tool. I am made by goowy.\n<A>Hej, jeg hedder Bob, og jeg arbejder hos Gooey.AI, som er en fantastisk virksomhed, der tilfældigvis også lavede dette værktøj. Jeg er lavet af Gooey.\nPROMPT: Please use the glossary to translate the following text from {{ source_language }} to {{ target_language }}.\n<Q>{{ text_to_translate }}\n<A>",
    "selected_models": ["palm2_chat"],
}

response = requests.post(
    "https://api.gooey.ai/v2/CompareLLM?example_id=a5vwv24t",
    headers={
        "Authorization": "bearer " + os.environ["GOOEY_API_KEY"],
    },
    json=payload,
)
assert response.ok, response.content

result = response.json()
print(response.status_code, result)
  1. Generate an api key below👇

  2. Install curl & add the GOOEY_API_KEY to your environment variables.
    Never store the api key in your code.

export GOOEY_API_KEY=sk-xxxx
  1. Run the following curl command in your terminal.
    If you encounter any issues, write to us at [email protected] and make sure to include the full curl command and the error message.
curl 'https://api.gooey.ai/v2/CompareLLM?example_id=a5vwv24t' \
  -H "Authorization: bearer $GOOEY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "input_prompt": "Remember this glossary of fixed translation terms. The columns represent language codes in BCP47 and the rows are the terms:\n{{ glossary }}\n\nPROMPT: Please use the glossary to translate the following text from en-US to da-DK.\n<Q>Hello, my name is Bob and I work at gooey.ai which is an awesome company that coincidentally also made this tool. I am made by goowy.\n<A>Hej, jeg hedder Bob, og jeg arbejder hos Gooey.AI, som er en fantastisk virksomhed, der tilf\u00e6ldigvis ogs\u00e5 lavede dette v\u00e6rkt\u00f8j. Jeg er lavet af Gooey.\nPROMPT: Please use the glossary to translate the following text from {{ source_language }} to {{ target_language }}.\n<Q>{{ text_to_translate }}\n<A>",
  "selected_models": [
    "palm2_chat"
  ]
}'

🎁 Example Response

{4 Items
"id"
:
string
"8odn74g1r9xt"
"url"
:
string
"https://gooey.ai/compare-large-language-models/"
"created_at"
:
string
"2023-09-23T01:34:10.442615+00:00"
"output"
:
{1 Items
"output_text"
:
{1 Items
"palm2_chat"
:
[
]1 Items
}
}
}

Please Login to generate the $GOOEY_API_KEY