This repository has been archived on 2025-09-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ChatGPT-PyAPI/cli.py

17 lines
467 B
Python
Executable file

#!/usr/bin/env python3
# Copyright (c) 2023 Julian Müller (ChaoticByte)
from os import environ
from sys import argv
from chatgpt_pyapi.openai import ChatGPT, Message, Models
# Read the API key from a environment variable
API_KEY = environ["OPENAI_API_KEY"]
if __name__ == "__main__":
# Create ChatGPT API instance
cgpt = ChatGPT(API_KEY, model=Models.GPT_35_TURBO_0301)
user_input = " ".join(argv[1:])
print(cgpt.chat(Message(user_input)).text)