파일 입력 지원 범위는 API 엔드포인트에 따라 다릅니다. Responses API는 아래에 나열된 파일 형식을 input_file 항목으로 받습니다. Chat Completions는 PDF 파일만 file 콘텐츠 파트로 받습니다.
| 입력 방식 | Responses API | Chat Completions |
|---|---|---|
Base64로 인코딩한 파일 데이터(file_data) |
아래에 나열된 파일 형식 지원 | PDF만 지원 |
업로드한 파일의 ID(file_id) |
아래에 나열된 파일 형식 지원 | PDF만 지원 |
외부 파일 URL(file_url) |
아래에 나열된 파일 형식 지원 | 지원하지 않음 |
PDF 이외의 파일을 입력으로 전달하려면 Responses API를 사용하세요. Chat Completions에서 파일의 텍스트를 사용하려면 애플리케이션에서 파일을 읽고 그 내용을 text 콘텐츠 파트로 보내세요.
파일 입력 처리 방식
Responses API는 파일 형식에 따라 input_file 항목을 다르게 처리합니다.
- PDF 파일:
gpt-4o와 이후 모델처럼 비전 기능을 지원하는 모델을 사용하면 API가 텍스트와 페이지 이미지를 모두 추출해 모델에 전달합니다. - PDF 이외의 문서 및 텍스트 파일(예:
.docx,.pptx,.txt, 코드 파일): API가 텍스트만 추출합니다. - 스프레드시트 파일(예:
.xlsx,.csv,.tsv): API가 아래에 설명된 스프레드시트 전용 데이터 보강 플로우를 실행합니다.
작업에 따라 다음 도구가 더 적합할 수 있습니다.
- 대용량 파일에서 필요한 내용을 검색하려면 파일 검색을 사용하세요. 파일 전체를
input_file로 직접 전달할 필요가 없습니다. - 집계, 조인, 차트 작성, 사용자 정의 계산 등 스프레드시트를 상세히 분석해야 하는 작업에는 호스팅 셸을 사용하세요.
PDF 이외의 파일에서 이미지와 차트 처리 시 제한 사항
Responses API는 PDF 이외의 파일에 삽입된 이미지나 차트를 추출해 모델 컨텍스트에 포함하지 않습니다.
차트와 다이어그램이 원본 그대로 전달되도록 하려면 먼저 파일을 PDF로 변환한 다음 PDF를 input_file로 보내세요.
스프레드시트 데이터 보강 방식
Responses API는 .xlsx, .xls, .csv, .tsv, .iif 등 스프레드시트 형식의 파일에 전용 데이터 보강 절차를 적용합니다.
API는 시트 전체를 모델에 전달하는 대신 각 시트의 첫 행부터 최대 1,000개 행을 파싱하고 모델이 생성한 요약과 헤더 메타데이터를 추가합니다. 이렇게 하면 모델은 더 작고 구조화된 형태의 데이터로 작업할 수 있습니다.
PDF 이미지의 세부 수준
Responses API에 PDF를 입력할 때 선택 사항인 detail 필드를 input_file 항목에 지정할 수 있습니다. auto, low, high 중 하나를 선택해 API가 페이지 이미지를 얼마나 상세하게 처리할지 조절하세요. detail을 생략하면 기본값은 auto입니다. GPT-5.6과 이후 모델에서 auto는 high를 사용하고, 이전 모델에서는 low를 사용합니다. 입력 토큰을 줄이려면 low를 사용하세요. 복잡한 차트, 작은 글씨, 다이어그램을 더 자세히 살펴봐야 한다면 high를 사용하세요.
detail 설정은 PDF 페이지 이미지 처리에만 영향을 줍니다. PDF에서 추출한 텍스트는 이 설정과 관계없이 모델 입력에 포함됩니다. Chat Completions의 파일 입력은 detail을 지원하지 않습니다.
다음은 이미지의 세부 수준을 높게 지정한 최소 구성의 Responses API 요청 본문입니다.
{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"filename": "document.pdf",
"file_data": "data:application/pdf;base64,...",
"detail": "high"
},
{
"type": "input_text",
"text": "Summarize this document."
}
]
}
]
}
지원하는 파일 형식
다음 표는 Responses API가 input_file 항목으로 받는 대표적인 파일 형식을 보여 줍니다. 확장자와 MIME 유형의 전체 목록은 이 페이지 아래쪽에서 확인할 수 있습니다. Chat Completions는 .pdf(application/pdf)만 지원하며, 이는 file_data와 file_id 모두에 적용됩니다.
| 분류 | 주요 확장자 |
|---|---|
| PDF 파일 | .pdf |
| 텍스트 및 코드 | .txt, .md, .json, .html, .xml, 코드 파일 |
| 서식 있는 문서 | .doc, .docx, .rtf, .odt |
| 프레젠테이션 | .ppt, .pptx |
| 스프레드시트 | .csv, .xls, .xlsx |
파일 URL
외부 파일의 URL을 지정해 해당 파일을 입력으로 전달할 수 있습니다.
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Analyze the letter and provide a summary of the key points."
},
{
"type": "input_file",
"file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
}
]
}
]
}'Chat Completions는 파일 URL을 지원하지 않습니다. 파일 URL을 사용하려면 Responses API를 사용하세요.
파일 업로드
다음 예시에서는 Files API로 파일을 업로드한 뒤 모델에 보내는 요청에서 해당 파일의 ID를 참조합니다.
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="user_data" \
-F file="@draconomicon.pdf"
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"file_id": "file-6F2ksmvXxt4VdoqmHRw6kL"
},
{
"type": "input_text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="user_data" \
-F file="@draconomicon.pdf"
curl "https://api.openai.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"messages": [
{
"role": "user",
"content": [
{
"type": "file",
"file": {
"file_id": "file-6F2ksmvXxt4VdoqmHRw6kL"
}
},
{
"type": "text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'Base64로 인코딩한 파일
Base64로 인코딩한 파일 데이터를 입력으로 보낼 수도 있습니다.
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"filename": "draconomicon.pdf",
"file_data": "...base64 encoded PDF bytes here..."
},
{
"type": "input_text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'curl "https://api.openai.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"messages": [
{
"role": "user",
"content": [
{
"type": "file",
"file": {
"filename": "draconomicon.pdf",
"file_data": "...base64 encoded bytes here..."
}
},
{
"type": "text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'사용 시 고려 사항
파일 입력을 사용할 때는 다음 사항을 고려하세요.
- 토큰 사용량: PDF를 파싱하면 추출한 텍스트와 페이지 이미지가 모두 컨텍스트에 포함되므로 토큰 사용량이 늘어날 수 있습니다. Responses API에서는
detail을auto(기본값),low,high중 하나로 설정해 PDF 페이지 이미지의 세부 수준을 조절할 수 있습니다. 대규모로 배포하기 전에 요금과 예상 토큰 사용량을 확인하세요. 요금 자세히 보기. - 파일 크기 제한: 한 요청에 여러 파일을 포함할 수 있지만 각 파일은 50 MB 미만이어야 합니다. 한 요청에 포함된 모든 파일의 크기 합계는 50 MB를 초과할 수 없습니다.
- 지원 모델: PDF에서 텍스트와 페이지 이미지를 함께 추출해 처리하려면
gpt-4o와 이후 모델처럼 비전 기능을 지원하는 모델이 필요합니다. - 파일 업로드 목적: 파일을 업로드할 때는 지원되는 목적 중 하나를 지정할 수 있습니다. 모델 입력으로 전달할 파일에는
user_data를 사용하세요.
지원하는 파일 형식 전체 목록
다음 목록은 Responses API에 적용됩니다. Chat Completions는 .pdf(application/pdf)만 지원하며, 이는 file_data와 file_id 모두에 적용됩니다.
| 분류 | 확장자 | MIME 유형 |
|---|---|---|
| PDF 파일 | PDF 파일(.pdf) |
application/pdf |
| 스프레드시트 | Excel 시트(.xla, .xlb, .xlc, .xlm, .xls, .xlsx, .xlt, .xlw) |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel |
| 스프레드시트 | CSV / TSV / IIF(.csv, .tsv, .iif), Google 스프레드시트 |
text/csv, application/csv, text/tsv, text/x-iif, application/x-iif, application/vnd.google-apps.spreadsheet |
| 서식 있는 문서 | Word/ODT/RTF 문서(.doc, .docx, .dot, .odt, .rtf), Pages, Google 문서 |
application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/msword, application/rtf, text/rtf, application/vnd.oasis.opendocument.text, application/vnd.apple.pages, application/vnd.google-apps.document, application/vnd.apple.iwork |
| 프레젠테이션 | PowerPoint 슬라이드(.pot, .ppa, .pps, .ppt, .pptx, .pwz, .wiz), Keynote, Google 프레젠테이션 |
application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.ms-powerpoint, application/vnd.apple.keynote, application/vnd.google-apps.presentation, application/vnd.apple.iwork |
| 텍스트 및 코드 | 텍스트 및 코드 형식(.asm, .bat, .c, .cc, .conf, .cpp, .css, .cxx, .def, .dic, .eml, .h, .hh, .htm, .html, .ics, .ifb, .in, .js, .json, .ksh, .list, .log, .markdown, .md, .mht, .mhtml, .mime, .mjs, .nws, .pl, .py, .rst, .s, .sql, .srt, .text, .txt, .vcf, .vtt, .xml) |
application/javascript, application/typescript, text/xml, text/x-shellscript, text/x-rst, text/x-makefile, text/x-lisp, text/x-asm, text/vbscript, text/css, message/rfc822, application/x-sql, application/x-scala, application/x-rust, application/x-powershell, text/x-diff, text/x-patch, application/x-patch, text/plain, text/markdown, text/x-java, text/x-script.python, text/x-python, text/x-c, text/x-c++, text/x-golang, text/html, text/x-php, application/x-php, application/x-httpd-php, application/x-httpd-php-source, text/x-ruby, text/x-sh, text/x-bash, application/x-bash, text/x-zsh, text/x-tex, text/x-csharp, application/json, text/x-typescript, text/javascript, text/x-go, text/x-rust, text/x-scala, text/x-kotlin, text/x-swift, text/x-lua, text/x-r, text/x-R, text/x-julia, text/x-perl, text/x-objectivec, text/x-objectivec++, text/x-erlang, text/x-elixir, text/x-haskell, text/x-clojure, text/x-groovy, text/x-dart, text/x-awk, application/x-awk, text/jsx, text/tsx, text/x-handlebars, text/x-mustache, text/x-ejs, text/x-jinja2, text/x-liquid, text/x-erb, text/x-twig, text/x-pug, text/x-jade, text/x-tmpl, text/x-cmake, text/x-dockerfile, text/x-gradle, text/x-ini, text/x-properties, text/x-protobuf, application/x-protobuf, text/x-sql, text/x-sass, text/x-scss, text/x-less, text/x-hcl, text/x-terraform, application/x-terraform, text/x-toml, application/x-toml, application/graphql, application/x-graphql, text/x-graphql, application/x-ndjson, application/json5, application/x-json5, text/x-yaml, application/toml, application/x-yaml, application/yaml, text/x-astro, text/srt, application/x-subrip, text/x-subrip, text/vtt, text/x-vcard, text/calendar |
다음 단계
다음 자료에서 더 자세히 알아보세요.