Config for Filesearch - max_results

OpenAI’s file search does have two parameters to configure the file_search tool response size the AI model receives back.

First, like you desire, one that promises to control the number of chunks returned (not files) - and there’s a possibility it could be working now if you want to try it:

The other parameter, that would serve better to reject irrelevant results - a semantic comparison threshold:

{
    "model": "gpt-4.1",
    "tools": [{
      "type": "file_search",
      "vector_store_ids": ["vs_1234567890"],
      "ranking_options": {"score_threshold": 0.40},
    }],...

Increasing the number ranged 0.0-1.0 increases the similarity score required for ranked chunks to appear.

OpenAI has no direct documentation of using score_threshold as plainly as my sample above: you have to expand the API reference several times to see API parameter inputs under “tools” to see it exists for the Responses API endpoint.

1 Like