Authentication with the OpenAI API is done using API keys.
In order to use the ChatGPT API, you need to include your secret API key as a Bearer token in the Authorization header. You would pass it like this:
```
import openai
openai.api_key = “YOUR_OPENAI_API_KEY”
response = openai.ChatCompletion.create(
model=“gpt-3.5-turbo”,
messages=[
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: “Who won the world series in 2020?”},
]
)
```
Remember to replace “YOUR_OPENAI_API\_KEY” with your actual OpenAI API key.
Security is very important when dealing with API keys. Do not expose the key in public repositories or other insecure places. It is recommended to store them securely, for example as environment variables on the system where your application is running.
If the key is compromised (i.e. someone else gets access to it), you should regenerate the key in the OpenAI API settings, which will invalidate the old one.
In the case of any security concerns, contact OpenAI support immediately.