Skip to content

New Official SDKs for TypeScript, Python and Go

SerpKite
Get API key

Python · langgraph

LangGraph + SerpKite

Wire Google search into a LangGraph StateGraph: take SerpKiteSearch from langchain-serpkite, bind it to the model, and route tool calls through a ToolNode. Full control over the loop, about 40 lines.

Overview

What LangGraph is, and where SerpKite fits

LangGraph models an agent as a graph of nodes over shared state. The standard tool-calling pattern is a model node, a ToolNode that executes tool calls, and tools_condition to decide whether to loop back or finish.

SerpKite plugs in as an ordinary LangChain tool from the official langchain-serpkite package. Because results come back as Markdown, the messages that flow through your graph stay small.

Setup

Set it up in 4 steps

  1. 1

    Get an API key

    Sign up (no card), create a key in the dashboard and export it as SERPKITE_API_KEY. New accounts get 2,500 free credits, then 1,000 every month.

    export SERPKITE_API_KEY=skt_live_…
  2. 2

    Install

    LangGraph plus a chat model provider.

    pip install -U langgraph langchain langchain-serpkite langchain-openai
  3. 3

    Define tools

    SerpKiteSearch for Google results and, optionally, a read_webpage tool built on SerpKiteWebpageLoader.

  4. 4

    Build the graph

    Add an agent node and a tools node, connect them with tools_condition, compile and invoke.

Code

Complete example

graph.py
from langchain.chat_models import init_chat_model
from langchain_core.tools import tool
from langchain_serpkite import SerpKiteSearch, SerpKiteWebpageLoader
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode, tools_condition


@tool
def read_webpage(url: str) -> str:
    """Fetch a public web page and return its main content as Markdown."""
    docs = SerpKiteWebpageLoader([url]).load()
    return docs[0].page_content if docs else "Could not read the page."


tools = [SerpKiteSearch(), read_webpage]  # SerpKiteSearch reads SERPKITE_API_KEY
llm = init_chat_model("openai:gpt-5-mini").bind_tools(tools)


def agent(state: MessagesState):
    return {"messages": [llm.invoke(state["messages"])]}


builder = StateGraph(MessagesState)
builder.add_node("agent", agent)
builder.add_node("tools", ToolNode(tools))
builder.add_edge(START, "agent")
builder.add_conditional_edges("agent", tools_condition)  # tool call → "tools", else END
builder.add_edge("tools", "agent")
graph = builder.compile()

out = graph.invoke({"messages": [("user", "Summarize this week's news about solid-state batteries.")]})
print(out["messages"][-1].content)

FAQ

LangGraph and SerpKite: common questions

Start building

Give your LangGraph project Google search

2,500 free credits, then 1,000 every month. No credit card.