Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AI Extraction

Use AI to extract metadata when traditional parsing fails.

Usage

url2ref-cli -u "https://example.com" --ai-extraction

# Specify provider and model
url2ref-cli -u "https://example.com" \
  --ai-extraction \
  --ai-provider openai \
  --ai-model gpt-4o-mini

API Keys

export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."

Providers & Models

ProviderModels
OpenAIgpt-4o, gpt-4o-mini
Anthropicclaude-3-haiku-20240307, claude-3-sonnet-20240229

Recommended: gpt-4o-mini or claude-3-haiku for cost-effective extraction.

When to Use

  • Pages without metadata markup
  • Old websites or blogs
  • When traditional extraction returns incomplete data

Combined with Translation

url2ref-cli -u "https://foreign-site.com/article" \
  --ai-extraction \
  --target-lang EN

Poor Extraction Quality

  • Try a more capable model (gpt-4o instead of gpt-4o-mini)
  • The page content might be JavaScript-rendered (AI can only see the initial HTML)

Slow Response

  • AI extraction adds 1-5 seconds depending on the model
  • Use faster models for better performance

Shell Configuration

# ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="your-key"
export ANTHROPIC_API_KEY="your-key"

# Alias for AI-assisted citations
alias cite-ai='url2ref-cli --ai-extraction --ai-provider openai --ai-model gpt-4o-mini'

Security Notes

  • API keys are read from environment variables only
  • Keys are never logged or stored
  • In the web interface, AI keys can be entered per-request (not stored server-side)

Next Steps