DEV Community

Discussion on: Getting Started with ElevenLabs Text-to-Speech API

Collapse
 
greg_cf3a672509a4 profile image
Greg

Would this approach expose your api key?

Collapse
 
thecmdrunner profile image
Pranav

Yes, this will include the API key in your frontend code. You should instead create an API endpoint or use Server Actions (if you're using nextjs) for this.

Collapse
 
ssk14 profile image
Sanjay 🥷

Hello @greg, we should always use API key as environment variables in .env files.

Collapse
 
msopacua profile image
msopacua

That doesn't help. The variables will be exposed, since the build process will include them in the generated bundle. Dotenv only prevents it to be exposed to the git repository.