OpenAI
OpenAI remains one of the most popular LLM providers, offering models with various levels of power suitable for different tasks, including GPT-4 and GPT-o1. LangChain provides seamless integration with OpenAI’s APIs, supporting both their traditional completion models and chat models. Each of these models has its own price, typically per token.
To work with OpenAI models, we need to obtain an OpenAI API key first. To create an API key, follow these steps:
- You need to create a login at https://platform.openai.com/.
- Set up your billing information.
- You can see the API keys under Personal | View API Keys.
- Click on Create new secret key and give it a name.
Here’s how this should look on the OpenAI platform:

Figure A.1: OpenAI API platform – Create new secret key
After clicking Create secret key, you should see the message API key generated. You need to copy the key to your clipboard and save it, as you will need it...