Skip to content

AI Provider Configuration

AI Alt Text supports multiple AI providers with vision capabilities. This document provides detailed configuration instructions for each provider.


Settings are resolved in the following priority order:

  1. PHP Constants (wp-config.php) - Highest priority
  2. Environment Variables - Second priority
  3. Database Settings (Admin UI) - Third priority
  4. Default Values - Fallback

When a setting is defined via constant or environment variable, the admin UI field becomes read-only and shows the source.


ModelDescriptionCost
gpt-4oBest quality, multimodal (recommended)$$$
gpt-4o-miniGood quality, lower cost$$
gpt-4-turboHigh quality, vision capable$$$
define( 'AI_ALT_TEXT_AI_PROVIDER', 'openai' );
define( 'AI_ALT_TEXT_OPENAI_KEY', 'sk-proj-xxxxxxxxxxxxxxxxxxxx' );
define( 'AI_ALT_TEXT_OPENAI_MODEL', 'gpt-4o' );
define( 'AI_ALT_TEXT_OPENAI_TYPE', 'openai' ); // 'openai' or 'azure'
Terminal window
AI_ALT_TEXT_AI_PROVIDER=openai
AI_ALT_TEXT_OPENAI_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxx
AI_ALT_TEXT_OPENAI_MODEL=gpt-4o
AI_ALT_TEXT_OPENAI_TYPE=openai
POST https://api.openai.com/v1/chat/completions

  • Azure subscription
  • Azure OpenAI Service resource
  • Deployed GPT-4o or GPT-4 Vision model
  1. Create an Azure OpenAI resource in the Azure Portal
  2. Deploy a vision-capable model (e.g., gpt-4o)
  3. Copy the endpoint URL and API key
define( 'AI_ALT_TEXT_AI_PROVIDER', 'openai' );
define( 'AI_ALT_TEXT_OPENAI_TYPE', 'azure' );
define( 'AI_ALT_TEXT_OPENAI_KEY', 'your-azure-api-key' );
define( 'AI_ALT_TEXT_OPENAI_MODEL', 'your-deployment-name' ); // Deployment name, not model name
define( 'AI_ALT_TEXT_AZURE_ENDPOINT', 'https://your-resource.openai.azure.com' );
define( 'AI_ALT_TEXT_AZURE_API_VERSION', '2024-02-15-preview' );
Terminal window
AI_ALT_TEXT_AI_PROVIDER=openai
AI_ALT_TEXT_OPENAI_TYPE=azure
AI_ALT_TEXT_OPENAI_KEY=your-azure-api-key
AI_ALT_TEXT_OPENAI_MODEL=your-deployment-name
AI_ALT_TEXT_AZURE_ENDPOINT=https://your-resource.openai.azure.com
AI_ALT_TEXT_AZURE_API_VERSION=2024-02-15-preview
POST {endpoint}/openai/deployments/{deployment}/chat/completions?api-version={api-version}

ModelDescriptionCost
claude-sonnet-4-20250514Best balance of quality and speed$$$
claude-3-5-sonnet-20241022Previous generation, still excellent$$
claude-3-haiku-20240307Fastest, lower cost$
define( 'AI_ALT_TEXT_AI_PROVIDER', 'anthropic' );
define( 'AI_ALT_TEXT_ANTHROPIC_KEY', 'sk-ant-xxxxxxxxxxxxxxxxxxxx' );
define( 'AI_ALT_TEXT_ANTHROPIC_MODEL', 'claude-sonnet-4-20250514' );
Terminal window
AI_ALT_TEXT_AI_PROVIDER=anthropic
AI_ALT_TEXT_ANTHROPIC_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxx
AI_ALT_TEXT_ANTHROPIC_MODEL=claude-sonnet-4-20250514
POST https://api.anthropic.com/v1/messages
  • Claude requires images to be sent as base64-encoded data
  • The plugin automatically handles image encoding

ModelDescriptionCost
gemini-2.0-flashLatest, fastest multimodalFree tier available
gemini-1.5-flashFast, good qualityFree tier available
gemini-1.5-proHighest quality$$
define( 'AI_ALT_TEXT_AI_PROVIDER', 'gemini' );
define( 'AI_ALT_TEXT_GEMINI_KEY', 'AIzaSyxxxxxxxxxxxxxxxxxxxx' );
define( 'AI_ALT_TEXT_GEMINI_MODEL', 'gemini-2.0-flash' );
Terminal window
AI_ALT_TEXT_AI_PROVIDER=gemini
AI_ALT_TEXT_GEMINI_KEY=AIzaSyxxxxxxxxxxxxxxxxxxxx
AI_ALT_TEXT_GEMINI_MODEL=gemini-2.0-flash
POST https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={api_key}
  • Gemini has a generous free tier (60 requests per minute)
  • Images are sent as base64-encoded data

  • Ollama installed locally or on a server
  • A vision-capable model pulled (e.g., llava)
Terminal window
# macOS
brew install ollama
# Linux
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama server
ollama serve
# Pull a vision model
ollama pull llava
ModelDescriptionSize
llavaLLaVA 7B, good quality4.7 GB
llava:13bLLaVA 13B, better quality8.0 GB
bakllavaBakLLaVA, alternative4.7 GB
llava-llama3LLaVA with Llama 35.5 GB
define( 'AI_ALT_TEXT_AI_PROVIDER', 'ollama' );
define( 'AI_ALT_TEXT_OLLAMA_ENDPOINT', 'http://localhost:11434' );
define( 'AI_ALT_TEXT_OLLAMA_MODEL', 'llava' );
Terminal window
AI_ALT_TEXT_AI_PROVIDER=ollama
AI_ALT_TEXT_OLLAMA_ENDPOINT=http://localhost:11434
AI_ALT_TEXT_OLLAMA_MODEL=llava
POST {endpoint}/api/generate
  • Free - No API costs, runs entirely locally
  • Requires local installation of Ollama
  • Processing speed depends on your hardware (GPU recommended)
  • For Docker deployments, use http://host.docker.internal:11434

If WordPress runs on a different server than Ollama:

define( 'AI_ALT_TEXT_OLLAMA_ENDPOINT', 'http://your-server-ip:11434' );

Make sure the Ollama server is accessible from your WordPress server.


ModelDescriptionCost
grok-2-vision-1212Vision-capable Grok 2$$
grok-vision-betaBeta vision model$$
define( 'AI_ALT_TEXT_AI_PROVIDER', 'grok' );
define( 'AI_ALT_TEXT_GROK_KEY', 'xai-xxxxxxxxxxxxxxxxxxxx' );
define( 'AI_ALT_TEXT_GROK_MODEL', 'grok-2-vision-1212' );
Terminal window
AI_ALT_TEXT_AI_PROVIDER=grok
AI_ALT_TEXT_GROK_KEY=xai-xxxxxxxxxxxxxxxxxxxx
AI_ALT_TEXT_GROK_MODEL=grok-2-vision-1212
POST https://api.x.ai/v1/chat/completions
  • Grok uses an OpenAI-compatible API format
  • Vision capabilities are available in Grok 2

VariableDescriptionDefault
AI_ALT_TEXT_AI_PROVIDERProvider: openai, anthropic, gemini, ollama, grokopenai
AI_ALT_TEXT_AUTO_GENERATEAuto-generate on upload: 1 or 01
AI_ALT_TEXT_OPENAI_TYPEOpenAI type: openai or azureopenai
AI_ALT_TEXT_OPENAI_KEYOpenAI/Azure API key(none)
AI_ALT_TEXT_OPENAI_MODELOpenAI model or Azure deployment namegpt-4o
AI_ALT_TEXT_AZURE_ENDPOINTAzure OpenAI endpoint URL(none)
AI_ALT_TEXT_AZURE_API_VERSIONAzure API version2024-02-15-preview
AI_ALT_TEXT_ANTHROPIC_KEYAnthropic API key(none)
AI_ALT_TEXT_ANTHROPIC_MODELAnthropic model nameclaude-3-5-sonnet-20241022
AI_ALT_TEXT_GEMINI_KEYGoogle AI API key(none)
AI_ALT_TEXT_GEMINI_MODELGemini model namegemini-1.5-flash
AI_ALT_TEXT_OLLAMA_ENDPOINTOllama server URLhttp://localhost:11434
AI_ALT_TEXT_OLLAMA_MODELOllama model namellava
AI_ALT_TEXT_GROK_KEYxAI API key(none)
AI_ALT_TEXT_GROK_MODELGrok model namegrok-2-vision-1212

All environment variables can also be defined as PHP constants in wp-config.php using the same names:

// Example: Full configuration for OpenAI
define( 'AI_ALT_TEXT_AI_PROVIDER', 'openai' );
define( 'AI_ALT_TEXT_AUTO_GENERATE', '1' );
define( 'AI_ALT_TEXT_OPENAI_KEY', 'sk-proj-xxxx' );
define( 'AI_ALT_TEXT_OPENAI_MODEL', 'gpt-4o' );

  • Ensure you’ve set both the API key and model for your chosen provider
  • Check that constants/environment variables are spelled correctly
  • Valid providers: openai, anthropic, gemini, ollama, grok
  • Check for typos in the provider name
  • Ensure the image URL is accessible
  • For local images, check file permissions
  • For remote images, ensure the server allows external requests
  • Verify the endpoint URL is correct (no trailing slash)
  • Ensure the deployment name matches exactly
  • Check the API version is supported
  • Ensure Ollama is running: ollama serve
  • Check the endpoint URL (default: http://localhost:11434)
  • Verify the model is pulled: ollama list

Add to wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Logs are written to wp-content/debug.log.

The plugin validates your configuration when you save settings. If there’s an error, you’ll see a warning message with details.

You can also test manually with curl:

Terminal window
# Test OpenAI
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer sk-proj-xxxx"
# Test Anthropic
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: sk-ant-xxxx" \
-H "anthropic-version: 2023-06-01"
# Test Ollama
curl http://localhost:11434/api/tags
# Test Gemini
curl "https://generativelanguage.googleapis.com/v1beta/models?key=AIzaSy-xxxx"
# Test Grok
curl https://api.x.ai/v1/models \
-H "Authorization: Bearer xai-xxxx"