Python · openai-agents
OpenAI Agents SDK + SerpKite
Add Google search to an OpenAI Agents SDK agent with a @function_tool, or connect SerpKite's remote MCP server and get search, news, maps, scholar and webpage tools at once.
Overview
What OpenAI Agents SDK is, and where SerpKite fits
The OpenAI Agents SDK is a lightweight Python framework for agents with tools, handoffs and guardrails. @function_tool turns a typed Python function into a tool; the docstring becomes its description.
Unlike a hosted web search tool, SerpKite gives you real Google results with country and language control and a price per call you can see in every response.
Setup
Set it up in 4 steps
-
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
Install
Set
OPENAI_API_KEYas well.pip install -U serpkite openai-agents -
3
Define a function tool
Decorate a function with
@function_tool. -
4
Run the agent
Runner.run_syncfor scripts,await Runner.runin async code.
Code
Complete example
from serpkite import SerpKite, SerpKiteError
sk = SerpKite() # reads SERPKITE_API_KEY
def serpkite_search(query: str, country: str = "us", num: int = 10) -> str:
"""Google search via SerpKite. Returns the results page as compact Markdown."""
try:
# format="markdown" returns a str: results, People Also Ask, related searches
return sk.search(query, country=country, num=num, format="markdown")
except SerpKiteError as e:
return f"Search failed: {e.message}"
from agents import Agent, Runner, function_tool
@function_tool
def google_search(query: str, country: str = "us") -> str:
"""Search Google for current information. Returns the top results with links, People Also Ask and related searches as Markdown. Use for recent events, facts and anything after your training cutoff.
Args:
query: What to search for.
country: Two-letter country code, e.g. us, gb, de.
"""
return serpkite_search(query, country)
agent = Agent(
name="Researcher",
instructions="Search the web before answering. Cite the URLs you used.",
tools=[google_search],
)
result = Runner.run_sync(agent, "What's new in the latest Postgres release?")
print(result.final_output)FAQ
OpenAI Agents SDK and SerpKite: common questions
Keep exploring
Related APIs and integrations
Start building
Give your OpenAI Agents SDK project Google search
2,500 free credits, then 1,000 every month. No credit card.