Guides · Web, domains and data
How do I automate SEO audits with a Python AI agent?
Bind seo-audit from the Strale LangChain toolkit to your model and give it a URL. The tool checks the page's title and description, headings, image alt text, canonical URL, Open Graph tags, structured data and robots.txt, and costs €0.30 a call.
- LangChain
- Python
Steps
- Install
langchain-straleand a chat-model package. - Create the toolkit with your Strale API key.
- Bind
seo-auditto your model. - Ask it to audit a URL and run the tool call the model returns.
The solution
# pip install langchain-strale langchain-openai
from langchain_strale import StraleToolkit
from langchain_openai import ChatOpenAI
toolkit = StraleToolkit(api_key="sk_live_YOUR_KEY")
tools = [t for t in toolkit.get_tools() if t.name == "seo-audit"]
llm = ChatOpenAI(model="gpt-4o").bind_tools(tools)
result = llm.invoke("Run an SEO audit on https://example.com")
# The model picks the tool and its arguments; your code runs the call.
for call in result.tool_calls:
tool = next(t for t in tools if t.name == call["name"])
print(tool.invoke(call["args"])) How it works
The answer has an overall_score, a checks object with the raw data for each signal, a flat issues list and prioritized_fixes, each with a high, medium or low priority. That gives your agent a ranked list of improvements instead of a pass or fail.
The tool's results include a language-model step, so wording can vary between runs. Its performance signal comes from the HTTP response, not from a full browser timing run: use Page Speed Test when you need Core Web Vitals. Backlinks and domain authority are not assessed.
bind_tools only lets the model propose a call. To have the model read the result and answer in words, put the same tools in one of LangChain's agent loops.
Tools in this guide
| Tool | Price per call |
|---|---|
| SEO Audit | €0.30 |
| Page Speed Test | €0.05 |
| Tech Stack Detection | €0.03 |
| URL to Markdown | Free |