Hello LLM with Python
To create a basic chat LLM application, we will use the OpenAI ChatGPT APIs to send a response and get a request. We will use the chatCompletions
API, which offers a multi-prompt array of messages to include conversation history.
You can find many examples of using the legacy single-prompt completions
API. This has been designed for models, most of which were deprecated in January 2024. For more details, see https://platform.openai.com/docs/api-reference/completions.
To create a simple ChatGPT app, follow these steps:
- Create an account with OpenAI at https://platform.openai.com/signup.
- Log in to OpenAI.
- Navigate to API Keys and create a new key. Ensure you copy this somewhere secure because it will not be displayed again.
- Test the API by listing the models you have access to, using
curl
to call themodels
endpoint:curl 'https://api.openai.com/v1/models' --header 'Authorization: Bearer <your API key>'
This should...