"The deployment failed to initialize due to a configuration or code error."

Question:
I’m not able to deploy a template Python app using the following autoscale settings:
Autoscale (1 vCPU / 4 GiB RAM)

I’m getting the following error:
2024-01-05T17:41:38Z error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information. For additional support, please post on … and a staff member will take a look.

Repl link/Link to where the bug appears:
https://korhan-open-ai-python-gpt-4-test-korhan.replit.app/

Screenshots, links, or other helpful context:
https://replit.com/@korhan/Korhan-OpenAI-Python-GPT-4-Test

import openai
import os
import sys

openai.api_key = os.environ['OPENAI_API_KEY']
if openai.api_key == "":
  sys.stderr.write("""
  You haven't set up your API key yet.

  If you don't have an API key yet, visit:

  https://platform.openai.com/signup

  1. Make an account or sign in
  2. Click "View API Keys" from the top right menu.
  3. Click "Create new secret key"

  Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
  """)
  exit(1)

response = openai.chat.completions.create(
    model="gpt-4",
    messages=[{
        "role": "system",
        "content": "You are a helpful assistant."
    }, {
        "role": "user",
        "content": "Who won the world series in 2020?"
    }, {
        "role":
        "assistant",
        "content":
        "The Los Angeles Dodgers won the World Series in 2020."
    }, {
        "role": "user",
        "content": "Where was it played?"
    }])

print(response)
1 Like

Hi @korhan , welcome to the forums!
You should not be deploying the bot as Autoscale as that is for websites, but instead as a Reserved VM.
However, your repl doesn’t appear to be a Discord/Telegram bot, so may I ask why you need to deploy this repl? Users won’t be able to run it either way.
Hope this helps!

1 Like