Tools for makers · Cloud and apps
OpenAI API (ChatGPT)
OpenAI's API gives your ESP32 access to the GPT models behind ChatGPT, so it can turn sensor readings into tips, greetings and answers on a screen.
- 3 lessons
What it is for
ChatGPT is a chat app made by OpenAI. The large language models behind it, called GPT, can also be reached through the OpenAI API. Any device that can reach the internet, including the ESP32, can send a question and get an answer back in a few seconds.
Your device sends a system prompt (who to be and how to answer) and a question as JSON over HTTPS, using the Responses API. The answer comes back as JSON too, and the board shows it on an LCD, speaks it or sends it to your phone.
The API is a paid service, and the account and API key must belong to an adult (18+). The short questions in our lessons cost well under a cent each. Set a low monthly budget in the settings.
Tips
- Keep your API key secret: never post a sketch online with the key in it, and delete keys you no longer use.
- Ask for short answers in the system prompt, so they fit small screens and stay cheap.
- Model names change over time: if a request fails with a model error, pick a current model on OpenAI's models page.