New ESP32-S3 development board is now available → /products
</>OceanLabz
Intermediate~15 min7 Oct 2026 · 4 min read

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.

API Keys & Connectivity Test

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)

  1. Go to platform.openai.com and log in.
  2. Click on Dashboard -> API Keys in the left menu.
  3. Click + Create new secret key.
  4. 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)

  1. Go to elevenlabs.io and log in.
  2. Click on your Profile Icon (top right) -> Profile + API Key.
  3. Click the "Eye" icon to reveal your API Key and copy it.

#C. ElevenLabs Voice ID

  1. Go to the VoiceLab tab.
  2. Choose a voice (e.g., "Adam" or a cloned voice).
  3. 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).