Skip to content

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.

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.

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.

Once enabled, configure your OpenRouter API credentials:

  1. Visit openrouter.ai/keys
  2. Sign up or log in to your OpenRouter account
  3. Create a new API key
  4. Copy the key (starts with sk-or-v1-)
  • 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.
  1. Click Refresh Models to load available vision-capable models from OpenRouter
  2. 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

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.

The AI uses two prompts to extract prescription data:

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.

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.

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.

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.

Once configured, staff members can use AI extraction when processing orders:

  1. Navigate to the order in WooCommerce > Orders
  2. View the prescription order item details
  3. Open the customer’s uploaded prescription image
  4. Click Extract with AI (when AI extraction is enabled)
  5. Review and verify the extracted values
  6. Approve or edit as needed

See Prescription Verification for the complete workflow.

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.

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.

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

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.

  • 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
  • Review the uploaded image quality
  • Check prompt configuration
  • Try a different model
  • Verify the prescription format is standard
  • Ensure API key is saved in production environment
  • Verify WordPress can make outbound HTTPS requests
  • Check server firewall allows connections to openrouter.ai