https://mcp.zenrows.com/mcp as a tool and let GPT invoke Zenrows’ scraping capabilities directly. No function-calling boilerplate, no orchestration code. Jump to Using Zenrows MCP with the Responses API for a complete code example.What is OpenAI?
OpenAI is the company behind GPT, the family of large language models powering ChatGPT and a developer platform used by hundreds of thousands of teams. The OpenAI API provides programmatic access to these models through the Responses API, the recommended interface for all new projects, with built-in support for function calling, structured outputs, reasoning models, and remote MCP servers. GPT models excel at reasoning, summarization, and structured generation, but they get blocked while accessing the web on their own, especially at scale. Pairing OpenAI with Zenrows closes that gap.Key benefits of integrating OpenAI with Zenrows
- Real-time web grounding for any GPT model: GPT has a fixed knowledge cutoff. Zenrows feeds live, up-to-date web content into any response, eliminating stale or hallucinated answers about recent events, prices, or product details.
- Anti-bot bypass out of the box: Adaptive Stealth Mode (
mode=auto) automatically handles JavaScript rendering, premium proxies, fingerprinting, and bot detection, so your AI can read pages that would block a regular scraper. - Token-efficient Markdown output: Zenrows returns clean Markdown in addition to raw HTML, which reduces token usage and improves model accuracy on the same context window.
- Native function calling: Expose Zenrows as a function tool and let GPT decide when to scrape based on the user’s question, with no orchestration code required.
- Works with every OpenAI API surface: Use Zenrows with the Responses API, structured outputs (
responses.parse), reasoning models, and the hosted MCP tool. The integration is a plain HTTP call, so it fits into any pattern. - MCP-ready out of the box: Plug the Zenrows hosted MCP server directly into the Responses API as a tool for zero-code access to all of Zenrows’ scraping capabilities.
Use cases
The OpenAI and Zenrows combination unlocks a wide range of AI workflows:- Web-aware chatbots: Build assistants that can answer questions about any URL the user provides, including protected sites like e-commerce stores, real estate portals, and news outlets.
- Real-time competitive intelligence: Have GPT analyze competitor pricing pages, product launches, and changelogs as they happen.
- Lead enrichment: Scrape company websites and let GPT extract industry, headcount signals, tech stack hints, and product summaries into your CRM.
- Automated research and reporting: Pull and summarize industry articles, financial filings, or technical documentation into ready-to-share briefs.
- Structured data extraction: Pull strongly-typed JSON (products, jobs, listings, reviews) from any page using GPT’s structured outputs grounded in Zenrows-scraped content.
Getting started: Basic Usage
Let’s start with a simple example: scrape a JavaScript-heavy, anti-bot-protected demo page using Zenrows and summarize it withgpt-5-mini through the Responses API.
Install the OpenAI Python library and requests
Create a .env file and set your API keys as environment variables
Run the following script
- Zenrows handles the scrape.
mode=autotells the API to start with the cheapest viable configuration and automatically escalate to JavaScript rendering or premium proxies if the target site requires it.response_type=markdownreturns clean Markdown instead of raw HTML, which is ideal for LLM context. - OpenAI handles the reasoning. The Markdown is fed into
client.responses.create(), with system-level guidance passed through theinstructionsparameter and the user prompt passed throughinput.
Advanced Usage: Building a web-aware AI assistant with function calling
Function calling is OpenAI’s mechanism for letting a model decide when to call an external tool. Instead of always scraping before each prompt, you expose Zenrows as a function and let GPT call it only when needed. This pattern is the foundation of any production-grade AI application that needs web access.Set up the environment
.env file:Define the scraping tool
name, description, and parameters at the top level of the tool object).Let GPT decide when to scrape
function_call item in the response output:input_list += response.output captures all output items, including reasoning, which must be passed back with tool call outputs for the model to continue correctly.Complete Code Example and Output
news.ycombinator.com, calls scrape_website with the right URL, then synthesizes a grounded answer from the scraped Markdown.
Structured data extraction
OpenAI’s structured outputs let you guarantee a model returns JSON that matches a specific schema. Combined with Zenrows, this is the cleanest way to extract typed data from any web page. The Responses API exposes structured outputs throughclient.responses.parse(), which takes a Pydantic model directly and returns a parsed Python object.
The example below scrapes a company homepage and extracts a strongly-typed CompanyInfo object:
Example output
mode=auto, and let GPT return validated JSON.
autoparse=true to your Zenrows request automatically identifies and extracts product details, article content, job listings, property data, and similar information into clean JSON, with no Pydantic schema or model call required.Zenrows Autoparse is included at no additional cost. Return the JSON directly to your application for known-structure pages, or pass it to GPT for downstream enrichment, normalization, or categorization. Pre-structured input also uses far fewer tokens than raw Markdown, which keeps your context window lean and your model calls cheaper.Note that Autoparse cannot be combined with response_type=markdown in the same request.Using Zenrows MCP with the Responses API
The Responses API natively supports remote Model Context Protocol (MCP) servers as tools. Zenrows publishes a hosted MCP server that exposes web scraping capabilities, so you can give GPT real-time web access without writing any function-calling boilerplate.server_urlpoints at Zenrows’ hosted MCP endpoint.authorizationcarries your Zenrows API key. OpenAI does not retain the value between requests, so it must be present on every API call.require_approval="never"skips the per-tool-call approval step, which is appropriate for trusted servers like Zenrows. To require explicit approval, remove this field or set it to"always".
API reference
The most useful Fetch parameters when working with OpenAI:Troubleshooting
Token limit exceeded
- Option 1: Use
response_type=markdown(already shown in every example above). Markdown reduces token usage significantly compared to raw HTML. - Option 2: Use the
css_extractororoutputsparameter to scrape only the parts of the page you need (a product card, a pricing table, an article body) instead of the entire DOM. - Option 3: Chunk the scraped content into smaller pieces, summarize each chunk separately, and combine the results, or switch to a model with a larger context window.
API key errors
- Option 1: Confirm both
ZENROWS_API_KEYandOPENAI_API_KEYare set in your environment. - Option 2: Verify your Zenrows API key in the dashboard and your OpenAI key in the OpenAI platform.
- Option 3: Check that your Zenrows subscription is active and has remaining quota on the Analytics page.
Empty or incomplete tool responses
- Option 1: Confirm
mode=autois set. Without it, JavaScript rendering and premium proxies are off by default and protected sites return blocked or empty pages. - Option 2: For sites that load content asynchronously, add
wait_for=<css-selector>(waits for a specific element) orwait=5000(waits a fixed duration in milliseconds). - Option 3: If the model is calling the tool with a malformed URL, tighten the function description in the JSON schema or add validation in your
scrape_websitewrapper before sending the request to Zenrows.
Reasoning items missing after tool calls
When using reasoning models likegpt-5, the response output may include reasoning items alongside function calls. Always append the entire response.output back to your input list (not just function calls) before sending the tool result. The pattern input_list += response.output shown in the function calling example handles this automatically.
Helpful resources
- Zenrows Fetch reference
- Zenrows MCP server documentation
- Adaptive Stealth Mode documentation
- Zenrows + OpenAI Agents SDK integration
- OpenAI Responses API guide
- OpenAI function calling guide
- OpenAI structured outputs guide
Frequently asked questions
Which OpenAI models work with this integration?
Which OpenAI models work with this integration?
gpt-4o, gpt-4o-mini, and other recent models. The hosted MCP tool requires a model that supports remote tools on the Responses API.How do I handle pages that exceed the model's token limit?
How do I handle pages that exceed the model's token limit?
response_type=markdown to keep token usage low; use css_extractor or outputs to scrape only the relevant section of the page; chunk the scraped content and summarize each chunk before combining, or switch to a model with a larger context window.Does Zenrows handle JavaScript-heavy and anti-bot-protected sites automatically?
Does Zenrows handle JavaScript-heavy and anti-bot-protected sites automatically?
mode=auto enables Adaptive Stealth Mode, which automatically activates JavaScript rendering, premium residential proxies, and stealth fingerprinting only when the target site requires them. You only pay for what succeeds.Can I use this with the OpenAI Agents SDK?
Can I use this with the OpenAI Agents SDK?
Can I let GPT browse multiple pages autonomously?
Can I let GPT browse multiple pages autonomously?
scrape_website repeatedly with different URLs, read what it gets back, and decide what to scrape next. For more complex agent behavior, pair this with the hosted MCP tool, which exposes a richer scraping surface without requiring you to maintain the function-calling loop yourself. For autonomous, multi-step research workflows, see the OpenAI Agents SDK integration guide.How does this compare to OpenAI's built-in web search tool?
How does this compare to OpenAI's built-in web search tool?
Is there a rate limit I should be aware of?
Is there a rate limit I should be aware of?
scrape_website wrapper.