AI
Pass

AI Email Triage Agent Skill - AI Pass API

AI Email Triage Agent Skill - AI Pass API

Add email triage capabilities to your AI agent. Categorize emails by urgency and importance with AI Pass API.

Quick Start

curl -X POST https://aipass.one/apikey/v1/chat/completions \
  -H "Authorization: Bearer $AIPASS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "messages": [
      {"role": "system", "content": "Categorize emails into: urgent, important, newsletter, spam"},
      {"role": "user", "content": "From: john@company.com\nSubject: Urgent meeting tomorrow\nBody: Need to discuss project deadline"}
    ],
    "temperature": 1,
    "max_tokens": 16000
  }'

Triage Single Email

triage_email() {
    local email="$1"
    
    curl -s -X POST https://aipass.one/apikey/v1/chat/completions \
        -H "Authorization: Bearer $AIPASS_API_KEY" \
        -H "Content-Type: application/json" \
        -d "{
            \"model\": \"openai/gpt-4.1-mini\",
            \"messages\": [
                {
                    \"role\": \"system\",
                    \"content\": \"Categorize this email into one of: urgent, important, newsletter, spam. Return JSON: {category, reason}\"
                },
                {
                    \"role\": \"user\",
                    \"content\": \"$email\"
                }
            ],
            \"temperature\": 1,
            \"max_tokens\": 16000
        }" | python3 -c "import json,sys; print(json.load(sys.stdin)['choices'][0]['message']['content'])"
}

Batch Triage

import requests
import os

class EmailTriageAgent:
    def __init__(self, api_key=None):
        self.api_key = api_key or os.environ.get("AIPASS_API_KEY")
        self.base_url = "https://aipass.one/apikey/v1"
        self.headers = {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json"
        }

    def triage_batch(self, emails):
        """Categorize multiple emails at once."""
        email_text = "\n---\n".join([
            f"From: {e['from']}\nSubject: {e['subject']}\nBody: {e['body']}"
            for e in emails
        ])

        response = requests.post(
            f"{self.base_url}/chat/completions",
            headers=self.headers,
            json={
                "model": "openai/gpt-4.1-mini",
                "messages": [
                    {
                        "role": "system",
                        "content": "Categorize each email: urgent, important, newsletter, spam. Return JSON: {categories: [{index, category, reason}]}"
                    },
                    {
                        "role": "user",
                        "content": f"Triage these:\n{email_text}"
                    }
                ],
                "temperature": 1,
                "max_tokens": 16000
            }
        )
        
        result = response.json()["choices"][0]["message"]["content"]
        return json.loads(result)

# Usage
agent = EmailTriageAgent()
emails = [
    {"from": "boss@company.com", "subject": "Urgent", "body": "Meeting now"},
    {"from": "newsletter@news.com", "subject": "Weekly", "body": "News"}
]
result = agent.triage_batch(emails)
print(result)

Cost

~$0.001 per 100 emails