AI
Pass

AI Document Analyzer Agent Skill — AI Pass API

AI Document Analyzer Agent Skill — AI Pass API

Skill for: Analyzing documents, extracting data, answering questions about document content API: AI Pass Chat Completions Endpoint: https://aipass.one/apikey/v1/chat/completions

Overview

This skill enables AI agents to analyze documents — PDFs, contracts, reports, research papers — and extract structured information, answer specific questions, or generate summaries. Works with any text content extracted from documents.

Skill Definition

name: document-analyzer
description: Analyzes document content using AI. Extracts key information, answers questions, and generates summaries from any text document.
version: 1.0.0
auth:
  type: api_key
  env: AIPASS_API_KEY
  header: "Authorization: Bearer $AIPASS_API_KEY"

Skill Content

import os
import requests

AIPASS_API_KEY = os.environ["AIPASS_API_KEY"]
BASE_URL = "https://aipass.one/apikey/v1"

def analyze_document(document_text: str, question: str = None, mode: str = "summary") -> dict:
    """
    Analyze a document using AI Pass API.
    
    Args:
        document_text: The full text content of the document
        question: Optional specific question about the document
        mode: "summary" | "qa" | "extract" | "compare"
    
    Returns:
        dict with analysis results
    """
    
    if mode == "summary":
        system = """You are an expert document analyst. Your job is to provide comprehensive document analysis.

When given a document, produce:
1. **Executive Summary** (2-3 sentences)
2. **Key Points** (bullet list, max 7 items)
3. **Important Data** (dates, numbers, names, entities)
4. **Conclusions/Recommendations** (if applicable)

Be precise, factual, and cite specific sections."""
        
        user_prompt = f"Analyze this document and provide a structured summary:\n\n{document_text}"
        
    elif mode == "qa":
        system = """You are an expert document analyst. Answer questions accurately based only on the provided document content. 
        
If the answer is not in the document, say so clearly. Quote relevant sections when helpful."""
        
        user_prompt = f"Document:\n{document_text}\n\nQuestion: {question}\n\nAnswer based solely on the document content:"
        
    elif mode == "extract":
        system = """You are a data extraction specialist. Extract structured data from documents.
        
Return data as JSON with these fields (if present):
- dates: list of important dates with context
- parties: list of people/organizations mentioned  
- monetary_values: list of amounts with context
- key_terms: important defined terms
- obligations: list of commitments/requirements
- deadlines: important deadlines"""
        
        user_prompt = f"Extract all structured data from this document:\n\n{document_text}"
    
    else:
        user_prompt = f"Document:\n{document_text}\n\nTask: {question}"
        system = "You are an expert document analyst."
    
    response = requests.post(
        f"{BASE_URL}/chat/completions",
        headers={
            "Authorization": f"Bearer {AIPASS_API_KEY}",
            "Content-Type": "application/json"
        },
        json={
            "model": "gpt-5-mini",
            "temperature": 1,
            "max_tokens": 16000,
            "messages": [
                {"role": "system", "content": system},
                {"role": "user", "content": user_prompt}
            ]
        }
    )
    
    result = response.json()
    return {
        "analysis": result["choices"][0]["message"]["content"],
        "mode": mode,
        "document_length": len(document_text),
        "model": "gpt-5-mini"
    }


def compare_documents(doc1: str, doc2: str, focus: str = None) -> dict:
    """
    Compare two documents and identify differences.
    
    Args:
        doc1: First document text
        doc2: Second document text  
        focus: Optional specific aspect to focus comparison on
    """
    
    focus_instruction = f"\nFocus particularly on: {focus}" if focus else ""
    
    response = requests.post(
        f"{BASE_URL}/chat/completions",
        headers={
            "Authorization": f"Bearer {AIPASS_API_KEY}",
            "Content-Type": "application/json"
        },
        json={
            "model": "gpt-5-mini",
            "temperature": 1,
            "max_tokens": 16000,
            "messages": [
                {
                    "role": "system",
                    "content": "You are an expert at comparing documents. Identify key differences, changes, and similarities between document versions."
                },
                {
                    "role": "user",
                    "content": f"Compare these two documents:{focus_instruction}\n\nDOCUMENT 1:\n{doc1}\n\nDOCUMENT 2:\n{doc2}\n\nProvide:\n1. Key differences\n2. Added content\n3. Removed content\n4. Changed terms/values"
                }
            ]
        }
    )
    
    result = response.json()
    return {
        "comparison": result["choices"][0]["message"]["content"],
        "model": "gpt-5-mini"
    }

Usage Examples

# Initialize with your API key
import os
os.environ["AIPASS_API_KEY"] = "$AIPASS_API_KEY"  # Set in your environment

# Summarize a contract
with open("contract.txt", "r") as f:
    contract_text = f.read()

summary = analyze_document(contract_text, mode="summary")
print(summary["analysis"])

# Answer a specific question
answer = analyze_document(
    contract_text, 
    question="What are the termination conditions?",
    mode="qa"
)
print(answer["analysis"])

# Extract structured data
data = analyze_document(contract_text, mode="extract")
print(data["analysis"])  # Returns JSON with dates, parties, values, etc.

# Compare two versions
with open("contract_v2.txt", "r") as f:
    contract_v2 = f.read()

diff = compare_documents(contract_text, contract_v2, focus="payment terms")
print(diff["comparison"])

Agent Integration Pattern

For agents that need to process documents as part of workflows:

class DocumentAnalyzerSkill:
    """Agent skill for document processing workflows."""
    
    name = "document_analyzer"
    description = "Analyzes documents: summarizes, answers questions, extracts data, compares versions"
    
    parameters = {
        "action": {
            "type": "string",
            "enum": ["summarize", "answer_question", "extract_data", "compare"],
            "description": "What to do with the document"
        },
        "document_text": {
            "type": "string",
            "description": "The document text content to analyze"
        },
        "question": {
            "type": "string",
            "description": "Question to answer (for answer_question action)"
        },
        "document2_text": {
            "type": "string",
            "description": "Second document for comparison (for compare action)"
        }
    }
    
    def execute(self, action: str, document_text: str, question: str = None, document2_text: str = None):
        if action == "summarize":
            return analyze_document(document_text, mode="summary")
        elif action == "answer_question":
            return analyze_document(document_text, question=question, mode="qa")
        elif action == "extract_data":
            return analyze_document(document_text, mode="extract")
        elif action == "compare":
            return compare_documents(document_text, document2_text)

Get Your API Key

  1. Sign up at aipass.one
  2. Go to Developer DashboardAPI Keys
  3. Create a new API key
  4. Set AIPASS_API_KEY in your environment

Try the app: aipass.one/apps/document-ai

Related skills: