For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
기본 탐색 메뉴
Theme

파일 검색

모델이 응답을 생성하기 전에 파일에서 관련 정보를 검색할 수 있도록 하세요.

파일 검색은 Responses API에서 제공하는 도구입니다. 모델은 이 도구로 의미 기반 검색과 키워드 검색을 수행해 미리 업로드한 파일로 구성된 지식 베이스에서 정보를 찾습니다. 벡터 스토어를 만들고 파일을 업로드하면 모델이 기존 지식에 더해 이러한 지식 베이스(vector_stores)의 정보도 활용할 수 있습니다.

벡터 스토어와 의미 기반 검색의 작동 방식은 검색 가이드를 참고하세요.

OpenAI가 이 도구를 호스팅하고 관리하므로 도구 실행을 처리하는 코드를 직접 작성할 필요가 없습니다. 모델은 파일 검색이 필요하다고 판단하면 자동으로 도구를 호출해 파일에서 정보를 찾고 결과를 반환합니다.

사용 방법

Responses API에서 파일 검색을 사용하려면 먼저 벡터 스토어에 지식 베이스를 구성하고 파일을 업로드해야 합니다.

지식 베이스를 구성한 후에는 모델이 사용할 수 있는 도구 목록에 file_search를 추가하고 검색할 벡터 스토어 목록을 함께 지정할 수 있습니다.

파일 검색 도구
from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-6-astra",
    input="What is deep research by OpenAI?",
    tools=[{"type": "file_search", "vector_store_ids": ["<vector_store_id>"]}],
)
print(response)

모델이 이 도구를 호출하면 응답에 다음 출력 항목이 포함됩니다.

  1. file_search_call 항목에는 파일 검색 호출의 ID가 포함됩니다.
  2. message 항목에는 모델의 응답과 파일 인용 정보가 포함됩니다.
파일 검색 응답
{
  "output": [
    {
      "type": "file_search_call",
      "id": "fs_67c09ccea8c48191ade9367e3ba71515",
      "status": "completed",
      "queries": ["What is deep research?"],
      "search_results": null
    },
    {
      "id": "msg_67c09cd3091c819185af2be5d13d87de",
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Deep research is a sophisticated capability that allows for extensive inquiry and synthesis of information across various domains. It is designed to conduct multi-step research tasks, gather data from multiple online sources, and provide comprehensive reports similar to what a research analyst would produce. This functionality is particularly useful in fields requiring detailed and accurate information...",
          "annotations": [
            {
              "type": "file_citation",
              "index": 992,
              "file_id": "file-2dtbBZdjtDKS8eqWxqbgDi",
              "filename": "deep_research_blog.pdf"
            },
            {
              "type": "file_citation",
              "index": 992,
              "file_id": "file-2dtbBZdjtDKS8eqWxqbgDi",
              "filename": "deep_research_blog.pdf"
            },
            {
              "type": "file_citation",
              "index": 1176,
              "file_id": "file-2dtbBZdjtDKS8eqWxqbgDi",
              "filename": "deep_research_blog.pdf"
            },
            {
              "type": "file_citation",
              "index": 1176,
              "file_id": "file-2dtbBZdjtDKS8eqWxqbgDi",
              "filename": "deep_research_blog.pdf"
            }
          ]
        }
      ]
    }
  ]
}

검색 설정

검색 결과 수 제한

Responses API의 파일 검색 도구를 사용할 때 벡터 스토어에서 가져올 검색 결과 수를 지정할 수 있습니다. 결과 수를 줄이면 토큰 사용량과 지연 시간을 줄일 수 있지만 답변 품질이 낮아질 수 있습니다.

검색 결과 수 제한
response = client.responses.create(
    model="gpt-6-astra",
    input="What is deep research by OpenAI?",
    tools=[
        {
            "type": "file_search",
            "vector_store_ids": ["<vector_store_id>"],
            "max_num_results": 2,
        }
    ],
)
print(response)

응답에 검색 결과 포함

출력 텍스트에서는 파일을 참조하는 주석을 확인할 수 있지만 파일 검색 호출은 기본적으로 검색 결과를 반환하지 않습니다.

응답에 검색 결과를 포함하려면 응답을 생성할 때 include 매개변수를 사용하세요.

검색 결과 포함
response = client.responses.create(
    model="gpt-6-astra",
    input="What is deep research by OpenAI?",
    tools=[
        {
            "type": "file_search",
            "vector_store_ids": ["<vector_store_id>"],
        }
    ],
    include=["file_search_call.results"],
)
print(response)

메타데이터 필터링

파일의 메타데이터를 기준으로 검색 결과를 필터링할 수 있습니다. 검색 가이드에서 다음 방법을 자세히 살펴보세요.

메타데이터 필터링
response = client.responses.create(
    model="gpt-6-astra",
    input="What is deep research by OpenAI?",
    tools=[
        {
            "type": "file_search",
            "vector_store_ids": ["<vector_store_id>"],
            "filters": {
                "type": "in",
                "key": "category",
                "value": ["blog", "announcement"],
            },
        }
    ],
)
print(response)

지원하는 파일 형식

MIME 유형이 text/로 시작하는 파일은 utf-8, utf-16, ascii 중 하나로 인코딩해야 합니다.

파일 형식 MIME 유형
.c text/x-c
.cpp text/x-c++
.cs text/x-csharp
.css text/css
.doc application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.go text/x-golang
.html text/html
.java text/x-java
.js text/javascript
.json application/json
.md text/markdown
.pdf application/pdf
.php text/x-php
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.py text/x-python
.py text/x-script.python
.rb text/x-ruby
.sh application/x-sh
.tex text/x-tex
.ts application/typescript
.txt text/plain

사용 시 참고 사항

API별 지원 여부요청 한도참고 사항

Build
500 RPM

Launch 및 Grow
1000 RPM

요금
ZDR 및 데이터 레지던시