3.2 KiB
3.2 KiB
Quick Start Guide
1. Get Your OpenRouter API Key
- Visit OpenRouter
- Sign up for a free account
- Go to Keys section
- Create a new API key
- Copy your API key
2. Configure the Tool
# Copy the environment template
cp .env.example .env
# Edit .env and add your API key
echo "OPENROUTER_API_KEY=your_key_here" >> .env
Or set it directly in your shell:
export OPENROUTER_API_KEY=your_key_here
3. Run Your First Analysis
# Basic usage
uv run pdf-to-kcf your_document.pdf
# This will create a file: your_document_insights.json
Example Output
The tool will generate a JSON file with structured insights like:
{
"insights": [
{
"type": "fact",
"insight": "The company revenue increased by 25% in Q4",
"content": "According to the financial report, Q4 revenue reached $2.5M, up 25% from Q3...",
"attributes": [
{"attribute": "source", "value": "Financial Report"},
{"attribute": "quarter", "value": "Q4"},
{"attribute": "confidence", "value": "high"}
]
},
{
"type": "opinion",
"insight": "The author recommends investing in AI infrastructure",
"content": "We strongly believe that investing in AI infrastructure is critical...",
"attributes": [
{"attribute": "sentiment", "value": "positive"},
{"attribute": "section", "value": "recommendations"}
]
}
]
}
Advanced Usage
Try Different Models
# Use GPT-4
uv run pdf-to-kcf document.pdf -m openai/gpt-4o
# Use Gemini
uv run pdf-to-kcf document.pdf -m google/gemini-pro-1.5
# Use Llama 3.1
uv run pdf-to-kcf document.pdf -m meta-llama/llama-3.1-70b-instruct
Custom Output Location
uv run pdf-to-kcf document.pdf -o /path/to/output.json
Start from Specific Page
# Start analysis from page 5 (0-indexed, so this is the 6th page)
uv run pdf-to-kcf document.pdf -s 5
How It Works
- The tool loads your PDF and extracts text
- An AI agent analyzes the content starting from page 0 (or your specified page)
- The agent autonomously decides if it needs to read more pages
- It extracts structured insights classified as facts, opinions, or comments
- Each insight includes the original content and relevant metadata
- Results are saved to a JSON file
Pricing
OpenRouter charges based on the model you use:
- Claude 3.5 Sonnet (default): ~$3 per million input tokens
- GPT-4o: ~$2.50 per million input tokens
- Llama 3.1 70B: ~$0.35 per million input tokens
Most PDFs will cost just a few cents to analyze.
Troubleshooting
"No API key found"
Make sure you've set OPENROUTER_API_KEY in your .env file or environment.
"Model not found"
Check the model name format: <provider>/<model-name> (e.g., anthropic/claude-3.5-sonnet)
See available models at https://openrouter.ai/models
"PDF not found"
Use the full path to your PDF file, or navigate to the directory containing it first.
Next Steps
- Read the full README.md for more details
- Check CLAUDE.md for architecture details
- See OpenRouter models for all available models