Zillow property data in the OpenAI Agents SDK
Give an OpenAI Agents SDK agent live U.S. property data through the ZillAPI MCP server, with no tool schemas to write.
The OpenAI Agents SDK connects to remote MCP servers with MCPServerStreamableHttp. Point it at the ZillAPI MCP server and your agent can look up a home by address or zpid, read its Zestimate and rent Zestimate, and search listings inside a map area. The tools call the same REST API as the rest of these docs, with the same API key.
Install
pip install openai-agentsThe code on this page was checked against openai-agents 0.25.0 on Python 3.12. The SDK needs Python 3.10 or later.
Add your keys
- Sign up and create a key on the API keys page. Keys start with
zk_. - Set it, and your model provider key, in the environment the agent runs in:
export ZILLAPI_KEY="zk_your_key_here"export OPENAI_API_KEY="sk-..."The ZillAPI key is only for property data. See Authentication for how keys work.
Connect the MCP server
import asyncioimport os
from agents import Agent, Runnerfrom agents.mcp import MCPServerStreamableHttp
async def main() -> None: async with MCPServerStreamableHttp( name="ZillAPI", params={ "url": "https://api.zillapi.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['ZILLAPI_KEY']}"}, "timeout": 60, }, client_session_timeout_seconds=60, cache_tools_list=True, ) as zillapi: agent = Agent( name="Property analyst", instructions="Answer with ZillAPI property data. Quote the numbers you used.", mcp_servers=[zillapi], ) result = await Runner.run( agent, "What is the Zestimate for 350 5th Ave, New York, NY 10118?" ) print(result.final_output)
asyncio.run(main())What the options do:
headerssends your key as aBearertoken on every request to the MCP server.timeoutandclient_session_give a property lookup up to 60 seconds. The SDK’s default session timeout is 5 seconds, which is short for a live lookup.timeout_seconds cache_tools_list=Truereads the tool list once per connection instead of on every run.
The tools your agent gets
| Tool | What it does | Required input |
|---|---|---|
lookup_property_by_address |
Full property record for a U.S. street address | address (street, city, state and ZIP) |
lookup_property_by_zpid |
Full property record for a Zillow property id | zpid |
get_zestimate |
Zestimate and rent Zestimate for a zpid | zpid |
search_listings |
For sale, for rent or sold listings inside a bounding box | bbox (west,south,east,north), status |
search_listings also takes beds_min, price_max and max_items (1 to 50). It needs coordinates, not a place name, so tell the agent the box or let it estimate one. Keep max_items small for chat answers. Costs per tool and plans are on the pricing page.
To expose only some tools, pass a filter:
import os
from agents.mcp import MCPServerStreamableHttp, create_static_tool_filter
zillapi = MCPServerStreamableHttp( name="ZillAPI", params={ "url": "https://api.zillapi.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['ZILLAPI_KEY']}"}, }, tool_filter=create_static_tool_filter( allowed_tool_names=["lookup_property_by_address", "get_zestimate"] ),)Prefer plain function tools?
If you want typed Python functions and full control over the requests, call the REST API from @function_tool functions instead of using MCP. The zillapi-openai-agents-example repository has five ready-made function tools (listing search, property details, Zestimate and comparable homes), streaming output and an offline test that runs without keys.
Troubleshooting
KeyError: 'ZILLAPI_KEY'. The variable is not set in the process that runs the agent. Export it in the same shell, or load it from your.envfirst.- Tool calls fail with an error about the API key. The key was rejected. Copy the whole key, starting with
zk_, or create a new one on the API keys page. - Timeouts on lookups. Raise
client_session_; the SDK default is 5 seconds.timeout_seconds - Search finds nothing. Check the bounding box order:
west,south,east,northin decimal degrees, with west less than east and south less than north.
Full error codes are listed on Errors.
FAQ
- How do I connect the OpenAI Agents SDK to ZillAPI?
- Open an MCPServerStreamableHttp connection to https://api.zillapi.com/mcp with the header Authorization: Bearer and your ZillAPI key, then pass the server in the mcp_servers list when you create the Agent. The agent sees four tools: lookup_property_by_address, lookup_property_by_zpid, get_zestimate and search_listings.
- Do I need to write tool schemas for ZillAPI in the Agents SDK?
- No. The Agents SDK lists the tools and their input schemas from the ZillAPI MCP server when the agent runs. If you prefer plain REST calls, write function tools instead; the zillapi-openai-agents-example repository shows that approach.
- Can I limit which ZillAPI tools the agent can call?
- Yes. Pass a tool_filter built with create_static_tool_filter and a list of allowed_tool_names to MCPServerStreamableHttp, for example to allow only lookup_property_by_address and get_zestimate.
Links
- OpenAI Agents SDK docs: Model context protocol (MCP)
- Function tools example: zillapi-openai-agents-example
- Other ways to connect: Vercel AI SDK, ChatGPT, MCP server and AI agents, REST quickstart
ZillAPI is an independent service, not affiliated with, endorsed by, or sponsored by Zillow Group, Inc. “Zillow” and “Zestimate” are trademarks of Zillow Group, Inc., used here descriptively. See Trademark & Affiliation.