# Use SimilarIQ with OpenAI Agents SDK

> The OpenAI Agents SDK can reach SimilarIQ's hosted MCP server two ways: as a hosted MCP tool that OpenAI's Responses API calls for you, or as a streamable HTTP server your own process connects to. Both expose ten tools; a look-alike search costs one credit, $0.25, and returns up to 100 ranked companies.

Source: https://similariq.ai/integrations/openai-agents-sdk · Updated 2026-11-25

## What the OpenAI Agents SDK is

The OpenAI Agents SDK is OpenAI's framework for building agents in code. You define an agent with instructions and tools, and a runner executes the loop of model calls and tool calls. Its Python documentation has a dedicated Model Context Protocol page describing several ways to attach MCP servers.

Two of those matter for a remote server like SimilarIQ's. The first is the hosted MCP tool, where, in the documentation's words, the Responses API calls a publicly reachable MCP server on the model's behalf. The second is a streamable HTTP server class, where your own process opens the connection and the SDK lists and calls tools locally.

SimilarIQ publishes no OpenAI-specific plugin or package. Its [MCP server](https://similariq.ai/mcp) is hosted at `https://similariq.ai/mcp`, is stateless, and uses streamable HTTP, so it fits both patterns without anything to install or run.

## Why connect it

An agent asked to "find companies like this one" has nothing to work from but the model's memory unless you give it a tool. SimilarIQ does one job: take a domain, run a fresh research pass, and return up to 100 look-alikes with a `matchScore`, a relationship `type`, a `confidence` score and a `likelyCompetitor` flag on each.

Those fields are what make the output usable inside an agent. A sales agent can keep rows typed Direct above a score of 70. A research agent can separate Emerging companies from established ones. A handoff to a second agent can pass a clean list of domains instead of a paragraph.

Billing stays simple. Tool calls from the SDK draw on the same pay-as-you-go balance as the web app and REST API, at the same price, with no separate API plan.

## Setup walkthrough: streamable HTTP server

This is the route with the most control, and the one whose authentication is fully documented for a static key.

Create a SimilarIQ API key in the app and store it in an environment variable. In your code, import `MCPServerStreamableHttp` from `agents.mcp`. The SDK documentation shows it taking a `params` dictionary with `url`, `headers` and `timeout` keys. Set the URL to `https://similariq.ai/mcp` and put the key in headers as `X-API-Key`, or as `Authorization` with a `Bearer` prefix. Open the server with `async with`, then pass it to the agent in the `mcp_servers` list.

One setting needs attention. The documentation says `client_session_timeout_seconds` controls the MCP session read timeout and defaults to 5 seconds. A SimilarIQ search is a fresh research pass that takes roughly 30 to 60 seconds, so the default will cut it off. Set it to 120 or more.

Two more documented options are useful. `cache_tools_list=True` stops the SDK re-listing tools on every run, which is safe here because the tool list is fixed. `max_retry_attempts` adds retries for tool listing and tool calls; be careful with it, because a retry issued after a client-side timeout can start a second paid search while the first is still running.

## Setup walkthrough: hosted MCP tool

In this pattern the tool call never touches your process. You add `HostedMCPTool` to the agent's `tools` list, not to `mcp_servers`. The documentation shows a `tool_config` dictionary with `"type": "mcp"`, a `server_label`, a `server_url` and a `require_approval` policy. The server must be publicly reachable, which SimilarIQ's is.

OpenAI's Responses API documentation describes an `authorization` field on the MCP tool and says the value is not stored and must be sent with every request. SimilarIQ accepts its key as a bearer token. This page did not verify end to end how that field is forwarded to a server that expects a static key, so run a free call such as the balance check first and confirm it returns your balance before relying on it.

Approvals are on by default. OpenAI's documentation says approval is requested before data is shared with a remote MCP server unless you set `require_approval` to `"never"` or exempt specific tools. A sensible configuration exempts the eight free tools and keeps approval on the two that spend credits.

## Example prompts and tasks

With the server attached, the agent can handle requests like these. The tool names are the ones the server exposes.

- "Find look-alikes for stripe.com and return the 20 highest match scores as a table." One call to `find_similar_companies`.
- "What is our balance?" A free call to `get_search_balance`.
- "List the last ten searches and reopen the one for our largest customer." `list_recent_searches`, then `get_search_results`, both free.
- "Start a bulk job for these 50 domains and report status." `start_bulk_search`, then `get_bulk_job`.
- "Save every Emerging company from that search." `save_company` for each, at no cost.
- "Create a share link for the search so legal can review it." `create_share_link`.
- "Which companies show up across all of our searches?" `list_my_companies`.

## Controlling spend

Only two tools cost credits: `find_similar_companies` at one credit per call and `start_bulk_search` at one credit per domain. Twenty searches cost $5.00; a thousand cost $250. Everything else, including reading past results, is free.

The SDK gives you code-level controls. The documentation describes `create_static_tool_filter` with `allowed_tool_names` and `blocked_tool_names`, so a read-only agent can be built by blocking the two paid tools. It also describes `require_approval` on the streamable HTTP server, accepting a per-tool map, so you can require a human or a callback to approve `find_similar_companies` while letting free tools run unattended.

SimilarIQ adds account-level limits that hold even if the code is wrong. With auto-refill off, the balance is the ceiling and the server returns an out-of-credits error when it is spent. With auto-refill on, the monthly cap is a hard limit on card charges. See [spend controls](https://similariq.ai/features/spend-controls).

## Two end-to-end workflows

**Prospecting with a handoff.** A first agent takes a customer domain, checks history for an existing search, and runs one if needed. It filters to Direct and Indirect results above a threshold and hands the domains to a second agent that owns your enrichment tools. SimilarIQ returns companies and scores, not contacts or headcount, so the second agent is where people and firmographics come from. The [look-alike prospecting](https://similariq.ai/use-cases/lookalike-prospecting) page describes the human version of this flow.

**Competitive watch.** A scheduled run searches your own domain, compares the result with the previous search read from history, and reports companies that are new or newly typed Emerging. Reading the earlier search is free, so each run costs $0.25. Have the agent save newcomers to the watchlist so a person can review them in the web app.

The SDK's documentation notes that tracing captures MCP activity, including tool listing and tool calls. Use the trace to confirm how many paid calls a run made before you schedule it.

## Troubleshooting and security

If a search fails with a timeout almost immediately, the session read timeout is still at its 5 second default. If no tools appear, check the URL and whether a tool filter is excluding them. An authentication failure means the key header is missing or the key was revoked. An out-of-credits response corresponds to HTTP 402 on the REST API, a rate-limit response to 429, and a failed search to 502, in which case the credit is refunded and a retry is safe.

OpenAI's own guidance on remote MCP servers is to use servers you trust, review what is sent to them, and keep approvals on for sensitive actions. Apply the same care here: the only thing a search sends to SimilarIQ is a company domain. Keep the key in an environment variable, give each agent its own key, and revoke a key from the SimilarIQ app if it leaks.

Treat returned company names as untrusted text, not instructions. If you prefer Anthropic's framework, the [Claude Agent SDK](https://similariq.ai/integrations/claude-agent-sdk) page covers the equivalent setup, and [LangChain](https://similariq.ai/integrations/langchain) has its own page.

## Frequently asked questions

### Does SimilarIQ work with the OpenAI Agents SDK?

Yes, through the hosted SimilarIQ MCP server. The SDK can attach it as a streamable HTTP server your process connects to, or as a hosted MCP tool called by OpenAI's Responses API. There is no separate SimilarIQ plugin to install.

### Which setup should I choose, hosted or streamable HTTP?

Choose streamable HTTP when you want to manage the connection, headers, timeouts and tool filtering yourself. Choose the hosted tool when you want OpenAI's infrastructure to make the call. The static-key header setup is fully documented for the streamable HTTP class.

### Why does my search time out after a few seconds?

The SDK's MCP session read timeout defaults to 5 seconds, and a SimilarIQ search takes roughly 30 to 60 seconds. Raise `client_session_timeout_seconds` to 120 or more.

### How do I stop an agent from spending credits?

Block `find_similar_companies` and `start_bulk_search` with a static tool filter, or require approval for those two tools. The remaining eight tools are free. A monthly cap on the SimilarIQ account is a hard ceiling regardless of what the code does.

### What does each tool call cost?

A search is one credit, $0.25, for up to 100 look-alikes. A bulk job is one credit per domain. Balance checks, history, saved companies and share links are free. See [pricing](https://similariq.ai/pricing).

### Can I skip MCP and call the REST API from a function tool?

Yes. Send `POST https://similariq.ai/api/v1/search` with a JSON body containing the domain and an `X-API-Key` header from any function you register as a tool. This page verified the SDK's MCP documentation only, so follow the SDK's own docs for defining function tools.
