All checks were successful
Build and Push AI Image / build-and-push (push) Successful in 43s
35 lines
829 B
Python
35 lines
829 B
Python
import os
|
|
import sys
|
|
from openai import OpenAI
|
|
|
|
|
|
def main():
|
|
api_key = os.getenv("OPENAI_API_KEY")
|
|
if not api_key:
|
|
print("ERROR: OPENAI_API_KEY environment variable is not set.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
# Az új OpenAI kliens automatikusan az OPENAI_API_KEY env-ből dolgozik
|
|
client = OpenAI()
|
|
|
|
prompt = "Please respond with exactly the string: hello world"
|
|
|
|
try:
|
|
response = client.responses.create(
|
|
model="gpt-4.1-mini",
|
|
input=prompt,
|
|
)
|
|
|
|
# Egyszerű, „naivan” kiszedjük a szöveget
|
|
msg = response.output[0].content[0].text
|
|
|
|
print("Model response:", msg)
|
|
|
|
except Exception as e:
|
|
print(f"ERROR while calling OpenAI API: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|