Store keys in wp-config.php
Updated September 15, 2026
The plugin recognises three constants you can define in wp-config.php so credentials aren’t stored in the database: AI_TTS_API_KEY for OpenAI, and AI_TTS_DROPBOX_APP_KEY and AI_TTS_DROPBOX_APP_SECRET for Dropbox (PRO). When a constant is defined, the matching settings field is disabled and marked as set in wp-config.php.
Add the constants
Edit wp-config.php and add the lines above /* That's all, stop editing! */:
define( 'AI_TTS_API_KEY', 'your-openai-secret-key' );
// PRO: Dropbox storage
define( 'AI_TTS_DROPBOX_APP_KEY', 'your-dropbox-app-key' );
define( 'AI_TTS_DROPBOX_APP_SECRET', 'your-dropbox-app-secret' );
You can also load the values from environment variables, for example define( 'AI_TTS_API_KEY', getenv( 'OPENAI_API_KEY' ) );, if your host supports them.
How each constant is used
AI_TTS_API_KEY: used for OpenAI requests when no key is saved in the settings. If a key is saved in the database too, the saved key takes priority. The settings field shows the first half of the constant’s value followed by asterisks.AI_TTS_DROPBOX_APP_KEYandAI_TTS_DROPBOX_APP_SECRET: always used instead of the settings fields when defined. You still need to click Connect to Dropbox once; the access and refresh tokens are stored in the database.
Known limitation with AI_TTS_API_KEY in 3.2.0
The AI TTS box in the post editor and the Generator page check for a key saved in the database before showing their controls. With only the constant defined, they display “Please enter your API key in the settings page” or “OpenAI API key required” and you can’t generate from them. Saving the settings page while the key field is disabled can also clear any key previously saved in the database.
Until this changes, the reliable setup is to save the key in AI Text-to-Speech › Settings › General Settings › OpenAI API Secret Key. The Dropbox constants aren’t affected by this limitation.
Keeping the key safe
- Create a dedicated OpenAI key for each site so you can revoke one without affecting others.
- Set a monthly budget limit in your OpenAI organisation settings.
- The plugin redacts keys and tokens from error messages it displays or logs, but don’t paste your key into support tickets.


