attestify-langchain
Official LangChain toolkit for Attestify — governed AI loop execution with signed receipts, audit trails, governance-docs semantic search, and x402-native payments on Base.
Install
pip install attestify-langchain
Requires Python ≥ 3.9 and langchain-core ≥ 0.1.
Quick Start
import os
from attestify_langchain import AttestifyToolkit
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
# 1. Create the toolkit with your API key
toolkit = AttestifyToolkit(api_key=os.environ["ATTESTIFY_API_KEY"])
tools = toolkit.create_tools()
# 2. Build the agent
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_messages([
["system", toolkit.system_prompt()],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# 3. Run it
result = executor.invoke({"input": "How many runs have I used this month?"})
print(result["output"])
Available Tools
| Tool | Description | Plan |
|---|---|---|
attestify_run_loop |
Submit a governed task to the loop router | All |
attestify_get_dashboard |
Run count, quota, plan tier, recent receipts | Builder+ |
attestify_get_recent_loops |
List recent loop receipts | All |
attestify_get_receipt |
Fetch a single receipt by loop_id |
All |
attestify_query_governance_docs |
Semantic search over Attestify's governance docs | All |
attestify_get_control_tower |
Live governance data (Enterprise only) | Enterprise |
Getting Your API Key
- Subscribe at attestifyos.com/pricing
- Your
att_live_...key arrives by email immediately after payment - Set it as an environment variable:
export ATTESTIFY_API_KEY=att_live_...
Toolkit Options
toolkit = AttestifyToolkit(
api_key="att_live_...",
base_url="https://attestifyos.com", # default
timeout_s=60, # default
max_retries=2, # default
include_control_tower=False, # set False for Builder-plan agents
include_rag=False, # set False to omit the governance-docs search tool
)
Callback Handler
Log loop completions (loop_id, cost, verified) automatically:
from attestify_langchain import AttestifyCallbackHandler
handler = AttestifyCallbackHandler(
on_run_complete=lambda loop_id, cost, verified:
print(f"Loop {loop_id} cost {cost} USDC verified={verified}")
)
executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
LangGraph Example
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from attestify_langchain import AttestifyToolkit
import os
toolkit = AttestifyToolkit(api_key=os.environ["ATTESTIFY_API_KEY"])
agent = create_react_agent(
ChatOpenAI(model="gpt-4o"),
toolkit.create_tools(),
state_modifier=toolkit.system_prompt(),
)
for chunk in agent.stream({"messages": [("human", "Submit a task: summarise Q2 revenue")]}):
print(chunk)
Plan Gating
All plan enforcement is server-side. If an agent calls attestify_get_control_tower on a Builder plan, it receives:
{"error": "Enterprise plan required to access Control Tower.", "status": 403}
The included system_prompt() instructs the agent to relay this gracefully to the user.
Links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file attestify_langchain-0.1.4.tar.gz.
File metadata
- Download URL: attestify_langchain-0.1.4.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3300c72a8bca0de2e9f803a2f10e60a11c14237e312e0c9c2dbccda7be44298c
|
|
| MD5 |
b25baf545665ac120b8a65a83ffabfe8
|
|
| BLAKE2b-256 |
2cd43231fe8cba27b8992a9734da8afe4bd221232612dbddceb143bdc4cc1bde
|
File details
Details for the file attestify_langchain-0.1.4-py3-none-any.whl.
File metadata
- Download URL: attestify_langchain-0.1.4-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3cc114f03fdb5e2cb6c89b4c39bfc61f2673f59164f9dbfe6c80cb44ba46989
|
|
| MD5 |
5559783223919a0681fc322bbed0dd8a
|
|
| BLAKE2b-256 |
268acd5a367bcd975c613f6a9ae5972be106f3e282f863dcdf7fc29425096b07
|