KeyBark

OpenAI hosted tool permissions: turn off web search and other tools per project

Hosted tools cost money on top of tokens: every web search call, every Code Interpreter session, every file search call. An agent that doesn't need them shouldn't be able to use them. OpenAI lets you switch each hosted tool on or off per project. Here is how, the organization setting that makes it fail if you skip it, how to cap tool calls per response, and how to see what tools cost.

Last reviewed 16 Nov 2026

The short version

  • Five tools, per project: file search, web search, image generation, remote MCP and Code Interpreter.
  • API: POST /v1/organization/projects/{project_id}/hosted_tool_permissions with e.g. {"web_search": {"enabled": false}}. GET on the same path reads all five. Needs an Admin API key.
  • Terraform: openai_project_hosted_tool_permissions with all five *_enabled fields.
  • Org policy first. To turn a tool off for one project, the organization's policy for that tool must be "selected projects". If it allows all projects, the change fails.
  • Per response: max_tool_calls on the Responses API caps built-in tool calls in one response.
  • Not a spend cap. An allowed tool can still run up a bill; pair it with a project hard limit.
Want a heads-up before the bill does?

KeyBark checks your OpenAI, Anthropic or OpenRouter spend about every 15 minutes during the beta and emails you when it crosses a daily or monthly threshold you set, or jumps above its 7-day average. It doesn't set or enforce limits for you. Free for one key, no card.

What each hosted tool costs

From OpenAI's pricing page (built-in tools, read 16 Nov 2026):

ToolPrice
Web search (web_search)$10 / 1k calls + search content tokens at model rates
Web search preview, reasoning models$10 / 1k calls + search content tokens at model rates
Web search preview, other models$25 / 1k calls, search content tokens free
File search$2.50 / 1k calls (Responses API) + storage $0.10 / GB per day after 1 GB free
Code Interpreter and Hosted Shell (containers)1 GB $0.03, 4 GB $0.12, 16 GB $0.48, 64 GB $1.92 per 20-minute session; eligible sessions billed by the minute, 5-minute minimum
Image generationImage model token rates (see the image generation section of the pricing page)

Tokens used by built-in tools are billed at the model's normal rates. For gpt-4o-mini and gpt-4.1-mini with the non-preview web search tool, search content is billed as a fixed block of 8,000 input tokens per call. In a web search response, only search actions carry the per-call fee; open_page and find_in_page don't (web search guide).

1. Set the organization policy

OpenAI's project controls guide says each organization-level hosted-tool policy has three modes: allow all projects, deny all projects or allow selected projects. A project can't disable a tool the organization has enabled for every project. So for any tool you want off in some projects, switch the organization policy to selected projects first. The project permission then decides, project by project.

The guide also notes that the setting can be changed in the dashboard (Terraform reports dashboard changes as drift). The docs we read don't give the exact menu path, so we don't either.

2. With the Admin API

From the Modify project hosted tool permissions reference, turn off web search, image generation and remote MCP for one project:

curl -X POST "https://api.openai.com/v1/organization/projects/$PROJECT_ID/hosted_tool_permissions" \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"web_search": {"enabled": false}, "image_generation": {"enabled": false}, "mcp": {"enabled": false}}'
  • Each body field (code_interpreter, file_search, image_generation, mcp, web_search) is optional and takes {"enabled": true|false}.
  • The response is the full permission object with all five tools and their enabled state.
  • Read it back any time with GET on the same path, for example in a nightly check across all your projects.
  • An Admin API key can only call administration endpoints, not models. Keep it in the job that sets up projects, never in the agent.

3. With Terraform

The same guide recommends setting every field so the config describes the whole policy:

resource "openai_project_hosted_tool_permissions" "agent" {
  project_id               = "proj_123"
  file_search_enabled      = true
  web_search_enabled       = false
  image_generation_enabled = false
  mcp_enabled              = false
  code_interpreter_enabled = false
}
  • Setting a field to false removes the project from that tool's selected-project policy; it fails if the organization allows the tool for all projects.
  • terraform plan -detailed-exitcode exits with 2 when someone changed a tool in the dashboard.
  • Removing this resource from your config only removes it from Terraform state; the remote settings stay as they are. (Removing openai_project_model_permissions is different: it deletes the model list. See OpenAI project model allowlist.)

Cap tool calls per response

When a project needs a tool, you can still limit how often one response uses it. The Responses API's max_tool_calls is the maximum number of built-in tool calls processed in a response, counted across all built-in tools, not per tool; further attempts by the model are ignored.

curl https://api.openai.com/v1/responses \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-6-astra", "tools": [{"type": "web_search", "search_context_size": "low"}],
       "max_tool_calls": 2, "input": "..."}'

The model is the one OpenAI's web search guide uses in its examples. search_context_size: "low" asks for less search context; OpenAI says it doesn't set an exact token count. Leave return_token_budget at its default; OpenAI warns that unlimited can increase cost (web search guide).

See what hosted tools cost you

The Costs API (GET /v1/organization/costs, Admin key) can group by project_id, line_item and api_key_id, filter with project_ids and line_items, and returns daily (1d) buckets. Group by project_id and line_item to see tool lines next to token lines per project; check the exact line item names in your own output before filtering on them. More on per-key costs: OpenAI cost per API key.

What hosted tool permissions can't do

  • No per-key setting. Every key in the project gets the same tools. One agent, one project.
  • No spend cap. An enabled tool can still bill without limit. That needs a project hard limit: OpenAI spend limit API.
  • Your own function tools aren't covered. These permissions are for OpenAI's hosted tools; tools your code runs are up to your code.
  • Not a leak response. A leaked key still works with every enabled tool. Delete it first: OpenAI API key leaked.
  • The Admin key can undo it. Anyone with it can turn tools back on. Treat it like a production secret.

Checklist for an agent project

  1. One project per agent, customer or environment.
  2. Organization policy set to selected projects for each tool you want to restrict.
  3. All five hosted tool permissions set explicitly; only what the agent needs is on.
  4. A model allowlist and per-model rate limits.
  5. max_tool_calls on requests that use tools.
  6. A project hard spend limit, plus something that tells you the same day when spend jumps.

Not sure your OpenAI (and Anthropic / OpenRouter) limits would stop a leaked key or a runaway loop? The free AI key limit audit walks through them in a few minutes (no sign-up, no key needed). Related: OpenAI project model allowlist, runaway AI agent cost, OpenAI spend limit API.

Where KeyBark fits (and where it doesn't)

KeyBark covers the "tell you the same day" item. With an OpenAI Admin key you connect, it reads your organization's costs from our servers about every 15 minutes during the beta and emails you when a daily or monthly threshold you set is crossed, or when today's spend jumps above its 7-day average.

Limits, honestly: KeyBark does not set or read hosted tool permissions, model permissions or spend limits, and it watches the organization total, not each project, tool or key. OpenAI's cost data comes in daily buckets and checks run on a schedule, so an alert can arrive after money has been spent. KeyBark is not a proxy and can't block a request; the project settings above are what stop traffic.

FAQ

Can I disable web search for one OpenAI project?

Yes, with an Admin API key: POST /v1/organization/projects/{project_id}/hosted_tool_permissions with {"web_search": {"enabled": false}}, or the Terraform resource openai_project_hosted_tool_permissions with web_search_enabled = false. It only works if the organization's web search policy is set to selected projects; if the organization allows the tool for all projects, disabling it for one project fails.

Which OpenAI hosted tools have project permissions?

Five: file search, web search, image generation, remote MCP servers and Code Interpreter. Each has its own enabled flag per project.

How much does OpenAI web search cost?

OpenAI's pricing page (read 16 Nov 2026) lists web search at $10 per 1,000 calls plus search content tokens billed at the model's rates. The older web_search_preview for non-reasoning models is $25 per 1,000 calls with free search content tokens. File search is $2.50 per 1,000 calls; Code Interpreter and Hosted Shell containers are billed per 20-minute session by memory size.

Does max_tool_calls cap spend?

Only per response. max_tool_calls on the Responses API limits the total number of built-in tool calls in one response, across all tools, and the model's further tool calls are ignored. It does nothing across requests, so an agent that loops still adds up. For a cost ceiling use a project hard spend limit.

Sources (read 16 Nov 2026): OpenAI Model, tool, and data controls with Terraform, API reference: modify and retrieve project hosted tool permissions, create a response (max_tool_calls), costs; pricing (built-in tools); web search guide. KeyBark is not affiliated with OpenAI.

Want a second line of defence?

KeyBark watches your OpenAI, Anthropic and OpenRouter spend from the server and flags a crossed threshold or spike by email and on your dashboard. Free for one key.