AI Extraction
The AI Extraction settings enable automated prescription reading using vision-capable AI models through OpenRouter. When enabled, the AI can automatically extract values from prescription images that customers have uploaded, reducing manual data entry time and errors for your staff.
Overview
Section titled “Overview”AI extraction uses vision-capable language models to analyze prescription images uploaded by customers and automatically populate the prescription fields in the order view. This feature is available to staff when reviewing and verifying prescription orders.
The system sends the uploaded prescription image along with configurable prompts to the AI model, which responds with structured JSON data containing the extracted prescription values.
Enable AI Extraction
Section titled “Enable AI Extraction”Navigate to SpecCart > Settings > AI Extraction and check Enable AI extraction.
When disabled, all AI-related fields are hidden and no API calls are made.
API Configuration
Section titled “API Configuration”Once enabled, configure your OpenRouter API credentials:
1. Get an OpenRouter API Key
Section titled “1. Get an OpenRouter API Key”- Visit openrouter.ai/keys
- Sign up or log in to your OpenRouter account
- Create a new API key
- Copy the key (starts with
sk-or-v1-)
2. Enter API Credentials
Section titled “2. Enter API Credentials”- API Endpoint: Pre-filled with
https://openrouter.ai/api/v1/chat/completions. Leave this as default unless using a compatible proxy. - API Key: Paste your OpenRouter API key here. The field is password-masked for security.
3. Select a Model
Section titled “3. Select a Model”- Click Refresh Models to load available vision-capable models from OpenRouter
- Select a model from the dropdown
Only models that support vision (image analysis) are shown. The list is filtered server-side to ensure compatibility.
Popular models for prescription extraction include:
- anthropic/claude-sonnet-4 (default) — Excellent accuracy, moderate cost
- openai/gpt-4o — Strong vision capabilities
- google/gemini-pro-vision — Cost-effective option
4. Test Connection
Section titled “4. Test Connection”Click Test Connection to verify your API credentials and selected model work correctly. A successful test confirms:
- API key is valid
- Endpoint is reachable
- Selected model is available
The test sends a simple request to the API without processing any real prescription data.
Extraction Prompts
Section titled “Extraction Prompts”The AI uses two prompts to extract prescription data:
System Prompt
Section titled “System Prompt”Sets the AI’s role and behavior. This establishes context for all extraction requests.
Default: Instructs the AI to act as an expert at reading eyeglass prescriptions with focus on accuracy and clarity.
User Prompt
Section titled “User Prompt”Provides specific instructions for each extraction request. Includes:
- What data to extract (sphere, cylinder, axis, add, prism, PD)
- Expected JSON output format
- Handling of missing or unclear values
Default: Detailed instructions specifying the JSON structure and field requirements.
Customizing Prompts
Section titled “Customizing Prompts”Advanced users can customize prompts to:
- Add support for specific prescription formats
- Include additional fields
- Adjust the AI’s behavior for specific use cases
Reset to Defaults button restores the original prompts if you need to undo changes.
Saving Settings
Section titled “Saving Settings”After configuring AI extraction settings, click Save AI Settings at the bottom of the section to persist your changes. A confirmation message will appear when settings are saved successfully.
Using AI Extraction
Section titled “Using AI Extraction”Once configured, staff members can use AI extraction when processing orders:
- Navigate to the order in WooCommerce > Orders
- View the prescription order item details
- Open the customer’s uploaded prescription image
- Click Extract with AI (when AI extraction is enabled)
- Review and verify the extracted values
- Approve or edit as needed
See Prescription Verification for the complete workflow.
Cost Considerations
Section titled “Cost Considerations”OpenRouter charges per API call based on:
- Selected model
- Size of the image
- Length of the response
Typical prescription extraction costs $0.001 to $0.01 per image depending on the model. Monitor your usage in the OpenRouter dashboard.
Important Notes
Section titled “Important Notes”Verification Required
Section titled “Verification Required”AI extraction is an assistive tool, not a replacement for professional verification. Prescription values should always be reviewed by qualified staff before fulfilling an order. Incorrect prescriptions can cause eye strain, headaches, or vision problems.
Data Privacy
Section titled “Data Privacy”Prescription images are sent to OpenRouter’s API for processing. Review OpenRouter’s privacy policy to ensure compliance with your local regulations (HIPAA, GDPR, etc.).
Images are:
- Transmitted over HTTPS
- Processed by the selected model provider (Anthropic, OpenAI, Google, etc.)
- Not stored permanently by SpecCart after extraction
Accuracy
Section titled “Accuracy”AI extraction accuracy depends on:
- Image quality (clear, well-lit, in-focus photos work best)
- Prescription format (standard formats work better than handwritten)
- Model selection (newer models generally perform better)
Encourage customers to upload high-quality images for best results.
Troubleshooting
Section titled “Troubleshooting””Failed to fetch models”
Section titled “”Failed to fetch models””- Verify your API key is correct
- Check your internet connection
- Ensure OpenRouter service is online
”Connection failed” on Test Connection
Section titled “”Connection failed” on Test Connection”- Double-check API key
- Verify API endpoint URL is correct
- Confirm selected model is available in your OpenRouter account
Extraction returns incorrect values
Section titled “Extraction returns incorrect values”- Review the uploaded image quality
- Check prompt configuration
- Try a different model
- Verify the prescription format is standard
API calls not working in production
Section titled “API calls not working in production”- Ensure API key is saved in production environment
- Verify WordPress can make outbound HTTPS requests
- Check server firewall allows connections to openrouter.ai
Next Steps
Section titled “Next Steps”- Prescription Verification — Learn the full prescription verification workflow
- Email Notifications — Configure prescription-related emails
- General Settings — Configure other SpecCart options