---
title: "Web search, MCP and code tools in one API call"
canonical: https://relayswitch.io/features/agent-tools
generated: 2026-11-02T10:15:47.178Z
source: https://api.relayswitch.io/v1/catalog
base_url: https://api.relayswitch.io/v1
---

Agent tools

# Web search, fetch, MCP and a code sandbox in one call.

Declare the tool your SDK already knows. The API runs it, hands the result back to the model and returns one answer with citations and a receipt for every round.

[Get an agent key](https://app.relayswitch.io/console)[Code](#example)

Live prices, per call

Web search

$0.01 a search

Web fetch

$0.001 a fetch

Code sandbox

$0.05 a container-hour, 1-minute minimum

Remote MCP tools

no fee, tokens only

Rounds per request

up to 8

## What it does for an agent

Search and read the web

web\_search finds pages, web\_fetch reads one. Sources come back as url\_citation annotations, Anthropic citations or Responses web\_search\_call items.

Run code

A sandbox that runs bash and JavaScript and python. Send the x-uplink-sandbox-session value back as session\_id and the next request finds the same files.

Call any remote MCP server

OpenAI's mcp tool or Anthropic's mcp\_servers: the API connects, lists the tools, calls them and feeds the answers to the model.

One request, many rounds

The loop runs on the API, up to max\_tool\_rounds or the x-uplink-max-tool-rounds header. Your agent code stays a single call.

A receipt per round

Each model round is billed and signed as its own request. x-uplink-round-ids lists them; x-uplink-total-charge is the whole bill.

Capped by the key

Tool fees count against the key's budget and monthly limit. At the limit the request stops with 402 and the rest of the account keeps running.

## Copy, paste, run

The OpenAI and Anthropic SDKs, unchanged except for the base URL.

OpenAI SDK: search and fetch

python

1`from openai import OpenAI`

2`import os`

3

4`client = OpenAI(`

5 `base_url="https://api.relayswitch.io/v1",`

6 `api_key=os.environ["RELAYSWITCH_API_KEY"],`

7`)`

8

9`resp = client.responses.create(`

10 `model="gpt-6.1-sol",`

11 `tools=[{"type": "web_search"}, {"type": "web_fetch"}],`

12 `input="What changed in the latest Node.js LTS release? Cite the notes.",`

13 `extra_body={"max_tool_rounds": 4},`

14`)`

15`print(resp.output_text) # url_citation annotations carry the sources`

Anthropic SDK: search and run code

python

1`import anthropic`

2`import os`

3

4`client = anthropic.Anthropic(`

5 `base_url="https://api.relayswitch.io/v1",`

6 `api_key=os.environ["RELAYSWITCH_API_KEY"],`

7`)`

8

9`reply = client.messages.create(`

10 `model="claude-sonnet-5-5",`

11 `max_tokens=2048,`

12 `tools=[`

13 `{"type": "web_search_20250305", "name": "web_search", "max_uses": 3},`

14 `{"type": "code_execution_20250825", "name": "code_execution"},`

15 `],`

16 `messages=[{"role": "user", "content":`

17 `"Find this week's ETH and BTC closes, then compute the ratio in code."}],`

18`)`

19`for block in reply.content:`

20 `if block.type == "text":`

21 `print(block.text)`

OpenAI SDK: remote MCP

python

1`from openai import OpenAI`

2`import os`

3

4`client = OpenAI(`

5 `base_url="https://api.relayswitch.io/v1",`

6 `api_key=os.environ["RELAYSWITCH_API_KEY"],`

7`)`

8

9`resp = client.responses.create(`

10 `model="gpt-6.1-sol",`

11 `tools=[{`

12 `"type": "mcp",`

13 `"server_label": "docs",`

14 `"server_url": "https://mcp.example.com/mcp",`

15 `"headers": {"Authorization": "Bearer " + os.environ["DOCS_MCP_TOKEN"]},`

16 `"allowed_tools": ["search_docs"],`

17 `"require_approval": "never",`

18 `}],`

19 `input="How do I rotate a webhook secret? Answer from our docs.",`

20`)`

21`print(resp.output_text)`

Anthropic SDK: remote MCP

python

1`import anthropic`

2`import os`

3

4`client = anthropic.Anthropic(`

5 `base_url="https://api.relayswitch.io/v1",`

6 `api_key=os.environ["RELAYSWITCH_API_KEY"],`

7`)`

8

9`reply = client.messages.create(`

10 `model="claude-sonnet-5-5",`

11 `max_tokens=1024,`

12 `tools=[{"type": "mcp_toolset", "mcp_server_name": "docs"}],`

13 `messages=[{"role": "user", "content": "List the open incidents."}],`

14 `extra_body={"mcp_servers": [{`

15 `"type": "url",`

16 `"name": "docs",`

17 `"url": "https://mcp.example.com/mcp",`

18 `"authorization_token": os.environ["DOCS_MCP_TOKEN"],`

19 `}]},`

20`)`

curl: what the call cost

bash

1`curl -i https://api.relayswitch.io/v1/chat/completions \`

2 `-H "Authorization: Bearer $RELAYSWITCH_API_KEY" \`

3 `-H "Content-Type: application/json" \`

4 `-d '{`

5 `"model": "gpt-6.1-sol",`

6 `"web_search_options": {},`

7 `"messages": [{"role": "user", "content": "Latest stable Rust version?"}]`

8 `}'`

9`# x-uplink-tool-calls: searches run x-uplink-tool-charge: their fees`

10`# x-uplink-total-charge: every model round plus the tool fees`

Sandbox files across requests

python

1`# Keep the sandbox's files between requests: send back the`

2`# x-uplink-sandbox-session header value as the tool's session_id.`

3`tools=[{"type": "code_interpreter", "session_id": "SANDBOX_SESSION_ID"}]`

## Every server tool, priced live

Read from GET /v1/catalog at render.

| Tool | Declare as | Price | Available |
| --- | --- | --- | --- |
| Web search | `uplink:web_search, web_search, web_search_preview, web_search_20250305` | $0.01 a search | Yes |
| Web fetch | `uplink:web_fetch, web_fetch, web_fetch_20250910` | $0.001 a fetch | Yes |
| Code sandbox | `uplink:code_execution, code_interpreter, code_execution_20250825` | $0.05 a container-hour, 1-minute minimum | Yes |
| Remote MCP tools | `uplink:mcp, mcp, mcp_servers` | no fee, tokens only | Yes |

Agent setup guides

-   [OpenClaw](https://relayswitch.io/guides/openclaw)
-   [Hermes Agent](https://relayswitch.io/guides/hermes-agent)
-   [OpenCode](https://relayswitch.io/guides/opencode)
-   [Claude Code](https://relayswitch.io/guides/claude-code)
-   [n8n](https://relayswitch.io/guides/n8n)

More features

-   [Files and redaction](https://relayswitch.io/features/files)
-   [Routing](https://relayswitch.io/features/routing)
-   [Caching and compression](https://relayswitch.io/features/caching)
-   [Guardrails and sign-in](https://relayswitch.io/features/guardrails)
-   [MCP gateway](https://relayswitch.io/features/mcp-gateway)
-   [Endpoints](https://relayswitch.io/features/endpoints)
-   [Key budgets](https://relayswitch.io/features/key-budgets)
-   [Observability](https://relayswitch.io/features/observability)
-   [Hosted agents](https://relayswitch.io/agents)
-   [Workflows](https://relayswitch.io/workflows)
-   [Docs](https://relayswitch.io/docs)

FAQs

## Questions

For agent builders.

Open the console

A key in under a minute

[Get a key](https://app.relayswitch.io/console)

Or email [hello@relayswitch.io](mailto:hello@relayswitch.io)

### 

### 

### 

### 

### 

### 

### 

### 

## Give your agent the web and a sandbox

One key, one request per answer, every tool call priced on the receipt.

[All features](https://relayswitch.io/features)[Get an agent key](https://app.relayswitch.io/console)

