AgentTax
Network
Blog
API Docs
Log In
LANGCHAIN INTEGRATION

LangChain Tax Compliance

Add sales tax calculation as a native LangChain tool. Your agents resolve tax obligations before invoicing — no guessing, no manual lookups, no compliance gaps.

INSTALL

pip install agenttax# or use REST directly

3-step setup

01
Get your API key
Sign up at agenttax.io — free tier, no credit card. You get 100 calls/month and an API key in under 60 seconds.
02
Add the tool to your LangChain agent
Use the Python SDK or call the REST endpoint directly. The tool takes a transaction object and returns the tax amount, rate, confidence, and jurisdiction details.
03
Pass tax context to your agent
Your agent can read the response and include tax in the final invoice, log the transaction, or flag edge cases for human review.

Define the LangChain tool

Wrap the AgentTax SDK in a @tool-decorated function. LangChain handles the rest — the agent will call it automatically when it needs tax information.

from langchain.tools import tool
from agenttax import AgentTaxClient

client = AgentTaxClient(api_key="atx_live_...")

@tool
def calculate_sales_tax(
    amount: float,
    buyer_state: str,
    transaction_type: str,
    counterparty_id: str,
    is_b2b: bool = False,
) -> dict:
    """Calculate US sales tax for an agent transaction.

    Args:
        amount: Transaction amount in USD
        buyer_state: Two-letter state code (e.g. 'CA', 'TX')
        transaction_type: Type of service ('saas', 'compute', 'consulting', etc.)
        counterparty_id: Unique ID of the buyer agent
        is_b2b: True if selling to another business

    Returns:
        dict with taxable, total_tax, combined_rate, confidence
    """
    return client.calculate(
        role="seller",
        amount=amount,
        buyer_state=buyer_state,
        transaction_type=transaction_type,
        counterparty_id=counterparty_id,
        is_b2b=is_b2b,
    )

Add to your agent

Pass it alongside your other tools. The agent decides when to call it based on context.

from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
from langchain.tools import tool

# Add the tool to your agent
tools = [calculate_sales_tax]

llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)

# Agent now resolves tax before invoicing
result = executor.invoke({
    "input": "I'm billing agent-buyer-42 $1,500 for compute work in Texas. What's the tax?"
})
# Agent calls calculate_sales_tax(1500, "TX", "compute", "agent-buyer-42")
# → taxable: True, total_tax: 75.00, combined_rate: 5%, confidence: high

Response shape

{
  "taxable": true,
  "total_tax": 75.00,
  "combined_rate": 0.05,
  "state_tax": 75.00,
  "local_tax": 0.00,
  "buyer_state": "TX",
  "transaction_type": "compute",
  "work_type": "compute",
  "classification_basis": "digital_service",
  "confidence": { "score": 95, "level": "high" },
  "advisories": ["TX §151.351: 80% of digital services taxable (20% statutory exemption)"],
  "transaction_id": "txn_abc123"
}

What the tool covers

50-state sales tax
All US jurisdictions including DC. Rates verified daily against 7 sources.
AI work-type classification
compute, research, content, consulting, trading — mapped to correct tax category per state.
B2B exemptions
Auto-detects business buyers from the AgentTax network. Applies B2B exemptions where applicable (e.g. Iowa §423.3).
Local rate lookup
Pass buyer_zip to get city/county combined rates (Chicago, NYC, LA, etc.).
Nexus monitoring
Every call updates cumulative revenue per state. Alerts when you cross economic nexus thresholds.
Confidence scoring
Every response includes a confidence score (0–100) and the sources backing the rate.

Other integrations

CrewAIAmpersendAPI DocsBlog

Start in 60 seconds

Free tier — 100 calls/month, no credit card. Upgrade when you need more.

AgentTax
Tax intelligence for AI-driven commerce. 50-state coverage, verified daily.

© 2026 Agentic Tax Solutions LLC. Tax rates verified daily against Tax Foundation, Sales Tax Institute, state DOR websites, Anrok, TaxJar, TaxCloud, and Kintsugi. AgentTax provides tax calculations for informational purposes only. Consult a qualified tax professional for compliance decisions.