API Keys & Connectivity Test
Acquire and securely configure OpenAI and ElevenLabs API keys, then run a connectivity test script to ensure your ESP32 can talk to AI cloud endpoints.

Now that our hardware (Microphone, Speaker, SD Card) is verified, we need to give our ESP32 the "keys" to access the AI brains in the cloud. Without valid credentials, the sophisticated code we write later will just be rejected by the servers.
This lesson focuses on acquiring your API Keys and running a connectivity test using the robust code you provided.
#Getting Your Credentials
We need three specific strings of text to make this work. Treat these like passwords—never share them publicly.
#A. OpenAI API Key (The Brain)
- Go to platform.openai.com and log in.
- Click on Dashboard -> API Keys in the left menu.
- Click + Create new secret key.
- Name it (e.g., "ESP32 Assistant") and copy the string starting with
sk-....- Note: You must have a small credit balance (e.g., $5) in your OpenAI account for this to work. It is not free.
#B. ElevenLabs API Key (The Voice)
- Go to elevenlabs.io and log in.
- Click on your Profile Icon (top right) -> Profile + API Key.
- Click the "Eye" icon to reveal your API Key and copy it.
#C. ElevenLabs Voice ID
- Go to the VoiceLab tab.
- Choose a voice (e.g., "Adam" or a cloned voice).
- Click the ID label or the copy icon next to the voice name to copy the Voice ID (a short string of random characters).
#The Connectivity Test Code
This code acts as a "sanity check." It connects to Wi-Fi, sends a simple "Hello" to ChatGPT, and requests a sample audio file from ElevenLabs. If this passes, your credentials are valid.
Prerequisite: You must install the ArduinoJson library via the Library Manager in Arduino IDE.
[object Promise]Upload the code and watch the Serial Monitor (115200 baud).