Help me understand the web tool cost!

Hello,

I’m trying to understand how the web tool cost is computed. I made 58 chat competions calls and that generated 119 web searches (according to the OpenAI developer platform). I don’t understand why it wouldn’t be 1:1 and is there a way to limit this? Then for those 119 web requests it charged me $1.19 - essentially 1c per web request. My understanding was that the cost was the output from the web search became an input token cost but it is charging for both the tool and the input tokens.

Any help here would be greatly appreciated!!!

Thanks,

Sharad

Yes, you are charged for both (see pricing for details).

You can limit it using the max_tool_calls parameter, but it might affect the quality of the response.

source - this one is for deep research but the concept is the same

3 Likes

@aprendendo.next - thanks for answering. Do you know if there is a way to pass in the paramater using the node SDK? I’m using the openai.responses.create method and I don’t see a parameter to pass this.

1 Like

The two above are not the same.

Chat Completions API endpoint requires you use a “search” AI model, that should have a fixed fee always there per use, and is always giving you search-powered answers in search style of output.

Responses API endpoint requires the web_search hosted tool be included in the tools list. The AI model can call that tool with multiple queries, and call it again for more additional fee billings before responding. The web result text placed as a tool response is more tokens you have to pay for in a second internal AI call iteration.

max_tool_calls” is a top-level parameter on the Responses API, accepting an integer. You can send that at the same level as model. (Chat Completions doesn’t need this, because you are always in control of your own function calls or even turning off function specs per-call.)

Sorry @_j I mis-typed it earlier. I was using the responses API earlier and said chat completion! I moved to the responses API because the guidance has been to use that. I’ll try using the parameter and see what it does - the code doesn’t like it because it is not available through the SDK.

OpenAI SDK input validation of unknown parameters blocking you from making requests (a silly code pattern) means you must update to and install the SDK-version-of-the-day to try newly released features or request JSON key/values older libraries don’t know about.

Or you could call the API with Content-Type: application/json HTTP requests and skip past version-gated code bloat.

(I’ve got an image edit app in another forum topic: UI is done loading and rendering before “import OpenAI” would be)

1 Like

@pepeg I don’t use openai-node too often, but I just tried and it really doesn’t show on code completion, and neither it appears in the package definition.

But on further inspection, if you add the parameter and observe the full response output in the console, you will notice it does recognize the parameter:

const response = await client.responses.create({
    model: "gpt-4.1-mini",
    input: "Show me the top 3 news for today",
    tools: [{ type: "web_search" }],
    max_tool_calls: 1,
});

console.log(JSON.stringify(response, null, 2));

it will show as:

...
  "max_output_tokens": null,
  "max_tool_calls": 1,  // <------ here
  "model": "gpt-4.1-mini-2025-04-14",
...