Understanding API authentication
Some websites are public, while others require you to log in before you can access content or functionality. The same is true for APIs. The Open-Notify API that we looked at in the Understanding APIs section is open to the public and doesn't require any kind of authentication. The OpenAI API, on the other hand, is private and therefore requires authentication to use it.
An API authentication process does the same thing as a website login, but in a way that is practical for applications rather than humans. There are many different ways in which APIs can authenticate application requests, but we're going to focus on one of the most common methods, basic authentication, because that's what the OpenAI API uses.
Basic authentication is an authentication method that is native to HTTP. It allows a username and password to be included in an HTTP header. To keep credentials secure, requests and responses to the API should be encrypted. So...