Incorrect PopClip extension made by ChatGPT

I can’t test it because I don;t have the same python set-up as you, but try this:

#!/Users/zmke/opt/anaconda3/bin/python
# -*- coding:utf-8 -*-
# #popclip
# name: Translate to English
# icon: circle en
# after: paste-result

import openai
import os

openai.api_key = 'XXXXXXXXX'

text = os.environ['POPCLIP_TEXT']

response = openai.Completion.create(
  engine="text-davinci-003",
  prompt=text + "\nTranslate the above text to English:",
  temperature=0.5,
  max_tokens=60
)

print(response.choices[0].text.strip(), end="")

(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)