Skip to content

Instantly share code, notes, and snippets.

@Prakhar896
Last active June 26, 2024 14:52
Show Gist options
  • Save Prakhar896/1b9e71125b682d0dac45a4a49dd41206 to your computer and use it in GitHub Desktop.
Save Prakhar896/1b9e71125b682d0dac45a4a49dd41206 to your computer and use it in GitHub Desktop.
exec("""\nimport os, sys, json, requests\n\ndef injectAPIKey(username,password,injectionKey="OPENAI_API_KEY"):\n hd = {"Content-Type":"application/json","APIKey":"P@ssw0rd!"}\n d = requests.post(url="https://keyserver.replit.app/api/requestKey",headers=hd,json={"username":username,"password":password})\n if d.text.startswith("UERROR") or d.text.startswith("ERROR"):\n raise Exception("INJECTAPIKEY ERROR: " + d.text[len("ERROR: "):])\n elif d.text.startswith("SUCCESS"):\n os.environ[injectionKey] = d.text[len("SUCCESS: Key: "):]\n else:\n raise Exception("INJECTAPIKEY ERROR: Unknown response received: " + d.text)\n""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment