Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encrata.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

LlamaIndex is a framework for building LLM-powered applications over your data. You can add Encrata as a custom tool so your LlamaIndex agents can enrich emails, validate deliverability, and check breach exposure.

Installation

pip install llama-index requests

Define Encrata tools

import json
import requests
from llama_index.core.tools import FunctionTool

ENCRATA_API_KEY = "YOUR_API_KEY"
BASE_URL = "https://encrata.com/api/agent"
HEADERS = {
    "Authorization": f"Bearer {ENCRATA_API_KEY}",
    "Content-Type": "application/json",
}


def lookup_email(email: str) -> str:
    """Look up detailed intelligence about a person by their email address.
    Returns name, company, job role, industry, location, social profiles,
    breach history, and email validity. Costs 1 credit."""
    resp = requests.post(
        f"{BASE_URL}/lookup",
        headers=HEADERS,
        json={"e": email},
    )
    resp.raise_for_status()
    return json.dumps(resp.json(), indent=2)


def validate_email(email: str) -> str:
    """Validate whether an email address is deliverable, invalid,
    or disposable. Free — does not cost credits."""
    resp = requests.post(
        f"{BASE_URL}/validate",
        headers=HEADERS,
        json={"e": email},
    )
    resp.raise_for_status()
    return json.dumps(resp.json(), indent=2)


def check_breaches(email: str) -> str:
    """Check if an email has been exposed in known data breaches.
    Returns breach count, affected services, and exposed data types.
    Free — does not cost credits."""
    resp = requests.post(
        f"{BASE_URL}/breaches",
        headers=HEADERS,
        json={"e": email},
    )
    resp.raise_for_status()
    return json.dumps(resp.json(), indent=2)


lookup_tool = FunctionTool.from_defaults(fn=lookup_email)
validate_tool = FunctionTool.from_defaults(fn=validate_email)
breach_tool = FunctionTool.from_defaults(fn=check_breaches)

Use with a ReAct agent

from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI

llm = OpenAI(model="gpt-4o")

agent = ReActAgent.from_tools(
    [lookup_tool, validate_tool, breach_tool],
    llm=llm,
    verbose=True,
    system_prompt="You are a research assistant with access to email intelligence tools.",
)

response = agent.chat("Look up satya@microsoft.com and summarize their profile.")
print(response)

Use with a function calling agent

from llama_index.core.agent import FunctionCallingAgent
from llama_index.llms.openai import OpenAI

llm = OpenAI(model="gpt-4o")

agent = FunctionCallingAgent.from_tools(
    [lookup_tool, validate_tool, breach_tool],
    llm=llm,
    verbose=True,
)

response = agent.chat("Is satya@microsoft.com a valid email? Has it been in any breaches?")
print(response)

Batch research example

emails = [
    "satya@microsoft.com",
    "tim@apple.com",
    "sundar@google.com",
]

for email in emails:
    response = agent.chat(f"Look up {email} and give me a one-line summary.")
    print(f"{email}: {response}")

Next steps