AgentTax
Network
Blog
API Docs
Log In
CREWAI INTEGRATION

CrewAI Tax Compliance

Give your CrewAI agents a native tax calculation tool. Individual agents or entire crews can resolve sales tax obligations before generating invoices — built for multi-agent workflows.

3-step setup

01
Install SDK
pip install agenttax — or call the REST endpoint directly. Get your API key at agenttax.io in under 60 seconds.
02
Define BaseTool subclass
Extend CrewAI's BaseTool with a Pydantic schema. The tool handles JSON validation and error handling automatically.
03
Assign to agents
Pass the tool to any agent in your crew. Use it in single-agent or multi-agent setups — tax validator crews work especially well.

Define the tool

CrewAI uses BaseTool with Pydantic schemas for typed input validation. This keeps the agent's arguments structured and predictable.

from crewai.tools import BaseTool
from pydantic import BaseModel, Field
from agenttax import AgentTaxClient

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

class TaxInput(BaseModel):
    amount: float = Field(description="Transaction amount in USD")
    buyer_state: str = Field(description="Two-letter US state code")
    transaction_type: str = Field(description="saas, compute, consulting, research, content")
    counterparty_id: str = Field(description="Unique ID of the buyer")
    is_b2b: bool = Field(default=False, description="Is this a B2B transaction?")

class SalesTaxTool(BaseTool):
    name: str = "calculate_sales_tax"
    description: str = (
        "Calculate US sales tax for a transaction. Returns the tax amount, "
        "combined rate, taxability, and confidence score. Use this before "
        "generating any invoice or payment request."
    )
    args_schema: type[BaseModel] = TaxInput

    def _run(self, amount, buyer_state, transaction_type, counterparty_id, is_b2b=False):
        result = client.calculate(
            role="seller",
            amount=amount,
            buyer_state=buyer_state,
            transaction_type=transaction_type,
            counterparty_id=counterparty_id,
            is_b2b=is_b2b,
        )
        return (
            f"Tax result for ${amount} {transaction_type} in {buyer_state}: "
            f"taxable={result['taxable']}, total_tax=${result['total_tax']:.2f}, "
            f"rate={result['combined_rate']*100:.2f}%, "
            f"confidence={result['confidence']['level']}"
        )

tax_tool = SalesTaxTool()

Single-agent crew

A billing agent that calculates tax before invoicing.

from crewai import Agent, Task, Crew

billing_agent = Agent(
    role="Billing Specialist",
    goal="Calculate the correct tax and generate accurate invoices for agent services",
    backstory="Expert in AI agent commerce tax obligations across all 50 US states",
    tools=[tax_tool],
    verbose=True,
)

tax_task = Task(
    description=(
        "Calculate the sales tax for this transaction: "
        "$2,500 SaaS service sold to agent-client-99 in New York. "
        "B2B transaction. Determine tax owed and generate the invoice total."
    ),
    expected_output="Invoice total including itemized tax breakdown",
    agent=billing_agent,
)

crew = Crew(agents=[billing_agent], tasks=[tax_task])
result = crew.kickoff()
# Agent calls calculate_sales_tax(2500, "NY", "saas", "agent-client-99", True)
# NY SaaS B2B: taxable, 4% state rate → $100 tax → total $2,600

Multi-agent: tax validator crew

Separate validator and sales agents — each with the tax tool. Good for high-value transactions requiring independent verification.

# Multi-agent crew: one agent sells, one validates tax compliance

tax_validator = Agent(
    role="Tax Compliance Validator",
    goal="Verify that every outbound invoice correctly reflects tax obligations",
    tools=[tax_tool],
)

sales_agent = Agent(
    role="Sales Agent",
    goal="Sell compute services and generate invoices",
    tools=[tax_tool],
)

validation_task = Task(
    description="Validate the tax calculation on invoice #4821 ($5,000 compute, TX, B2B)",
    agent=tax_validator,
)

# TX compute B2B: 80% taxable rule → $5,000 × 80% × 6.25% = $250 tax

What your crew gets

50-state coverage
All US jurisdictions, verified daily. States updated automatically when rates change.
AI service classification
Maps compute, research, content, consulting, trading to the correct tax category per state.
Per-agent nexus tracking
Each agent's transactions accumulate separately. Alerts when you approach economic nexus thresholds.
Structured JSON output
Consistent response shape — easy for agents to parse and include in downstream tasks.
B2B/B2C split rules
Applies Maryland's B2B/B2C rate distinction, Iowa's B2B exemption, and other state-specific rules.
Capital gains tracking
Separate endpoint for digital asset trades — FIFO/LIFO/Specific ID, 1099-DA export.

Other integrations

LangChainAmpersendAPI DocsBlog

Start in 60 seconds

Free tier — 100 calls/month, no credit card. Your crew will be filing correct taxes before your next coffee.

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.