To help models understand PDF content, we put into the model’s context both the extracted text and an image of each page. The model can then use both the text and the images to generate a response. This is useful, for example, if diagrams contain key information that isn’t in the text.
Example
OpenAI SDK Python
import osimport base64import requestsfrom openai import OpenAI# Create a file in OpenAIopenai_client = OpenAI()pdf_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" # This is a dummy PDF file, you can use any PDF file you wantresponse = requests.get(pdf_url)file_data = response.contentfile = openai_client.files.create(file=file_data, purpose="user_data")# Create a client for KeywordsAI proxyclient = OpenAI( base_url="https://api.keywordsai.co/api", api_key=os.getenv("KEYWORDSAI_API_KEY_TEST"),)model = "gpt-4.1"file_content = [ {"type": "text", "text": "What's this file about?"}, { "type": "file", "file": { "file_id": file.id, }, }]response = client.chat.completions.create( model=model, messages=[ { "role": "user", "content": file_content, } ],)assert response is not None
{"docsConfig":{"theme":"maple","$schema":"https://mintlify.com/docs.json","name":"Docs","colors":{"primary":"#6483F0","light":"#7590F2","dark":"#05050A"},"logo":{"light":"https://mintcdn.com/keywordsai/3H_f_DB_lrXdnPkU/logo/light.svg?fit=max\u0026auto=format\u0026n=3H_f_DB_lrXdnPkU\u0026q=85\u0026s=67935f91b2af1c19b15292f0e274d207","dark":"https://mintcdn.com/keywordsai/3H_f_DB_lrXdnPkU/logo/dark.svg?fit=max\u0026auto=format\u0026n=3H_f_DB_lrXdnPkU\u0026q=85\u0026s=d9dec9586bcf34e6d2d34ffffe805238","href":"https://www.keywordsai.co"},"favicon":"/logo.svg","api":{"playground":{"display":"interactive"},"mdx":{"auth":{"method":"bearer","name":"Authorization"},"server":"https://api.keywordsai.co"}},"background":{"color":{"light":"#ffffff","dark":"#05050A"}},"navbar":{"links":[{"href":"https://discord.com/invite/KEanfAafQQ","label":"Discord"}],"primary":{"type":"button","label":"platform","href":"https://platform.keywordsai.co/"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/keywordsai","github":"https://github.com/keywordsai","discord":"https://discord.com/invite/KEanfAafQQ"}},"search":{"prompt":"Search..."},"seo":{"metatags":{"og:site_name":"Keywords AI | LLM monitoring platform","og:image":"/logo.svg","twitter:site":"@keywordsai"},"indexing":"all"},"fonts":{"heading":{"family":"Inter"},"body":{"family":"Inter"}},"styling":{"codeblocks":"system","latex":true},"integrations":{"posthog":{"apiKey":"phc_rL8MrmFrie28wgxtDurKt9t1bwCzChaJQ7WYaj1F1gH"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"keywordsai","hasAudioNarration":false,"actualSubdomain":"keywordsai","customDomains":["docs.keywordsai.co"],"gitSource":{"type":"github","owner":"respanai","repo":"keywords-ai-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true,"issues":true,"edits":true},"entitlements":{},"buildId":"6ae91e42abde022f2c1eef81:success","clientVersion":"0.0.4347","searchFilterCounts":[{"language":"default","tag":"API reference","count":113},{"language":"default","tag":"Documentation","count":91},{"language":"default","tag":"SDKs","count":72},{"language":"default","tag":"Features","count":66},{"language":"default","tag":"Integrations","count":57},{"language":"default","tag":"Evals","count":45},{"language":"default","tag":"Develop","count":42},{"language":"default","tag":"Keywords AI SDK","count":29},{"language":"default","tag":"Experiments","count":27},{"language":"default","tag":"Client API","count":27}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"documentation/products/gateway/advanced_features/upload_pdf","slug":"/documentation/products/gateway/advanced_features/upload_pdf","pageMetadata":{"title":"Upload PDF","description":"Learn how to use PDF files with Keywords AI.","href":"/documentation/products/gateway/advanced_features/upload_pdf","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Learn how to use PDF files with Keywords AI.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Heading}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`To help models understand PDF content, we put into the model’s context both the extracted text and an image of each page. The model can then use both the text and the images to generate a response. This is useful, for example, if diagrams contain key information that isn’t in the text.`}),`\n`,_jsx(Heading,{level:`2`,id:`example`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:`OpenAI SDK Python`,highlight:`[21,22,23,24,25,26,27,28,29,30]`,numberOfLines:`40`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`40`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` base64`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Create a file in OpenAI`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`openai_client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`pdf_url `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # This is a dummy PDF file, you can use any PDF file you want`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.get(pdf_url)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`file_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.content`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`file`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai_client.files.create(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`file`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`file_data, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`purpose`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Create a client for KeywordsAI proxy`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.keywordsai.co/api\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.getenv(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"KEYWORDSAI_API_KEY_TEST\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`model `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"gpt-4.1\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`file_content `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What's this file about?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line line-highlight`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"file\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"file\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"file_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`file`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.id,`})]}),`\n`,_jsx(_components.span,{className:`line line-highlight`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line line-highlight`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line line-highlight`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})}),`\n`,_jsx(_components.span,{className:`line line-highlight`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`model,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: file_content,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`assert`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`is`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` not`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Upload PDF","description":"Learn how to use PDF files with Keywords AI.","href":"/documentation/products/gateway/advanced_features/upload_pdf","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Example","slug":"example","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"keywordsai","siteName":"Docs","title":"Upload PDF - Docs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-28T19:11:54.638Z","originalFileLocation":"documentation/products/gateway/advanced_features/upload_pdf.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Learn how to use PDF files with Keywords AI.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Upload PDF - Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Learn how to use PDF files with Keywords AI.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Keywords AI | LLM monitoring platform\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://keywordsai.mintlify.site/logo.svg\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Upload PDF - Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Learn how to use PDF files with Keywords AI.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://keywordsai.mintlify.site/logo.svg\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/keywordsai/fc9w4zZL5FST7wUY/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6483F0\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/documentation/products/gateway/advanced_features/upload_pdf.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.keywordsai.co/#organization\",\"name\":\"Docs\",\"url\":\"https://docs.keywordsai.co\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/keywordsai/3H_f_DB_lrXdnPkU/logo/light.svg?fit=max\u0026auto=format\u0026n=3H_f_DB_lrXdnPkU\u0026q=85\u0026s=67935f91b2af1c19b15292f0e274d207\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.keywordsai.co#website\",\"name\":\"Docs\",\"url\":\"https://docs.keywordsai.co\",\"publisher\":{\"@id\":\"https://docs.keywordsai.co/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf#webpage\",\"url\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf\",\"name\":\"Upload PDF\",\"description\":\"Learn how to use PDF files with Keywords AI.\",\"dateModified\":\"2026-01-28T19:11:54.638Z\",\"isPartOf\":{\"@id\":\"https://docs.keywordsai.co#website\"},\"breadcrumb\":{\"@id\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Features\",\"item\":\"https://docs.keywordsai.co/documentation/products/dashboard/metrics\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LLM Gateway\",\"item\":\"https://docs.keywordsai.co/get-started/quickstart/gateway\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Upload PDF\",\"item\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf#article\",\"headline\":\"Upload PDF\",\"name\":\"Upload PDF\",\"description\":\"Learn how to use PDF files with Keywords AI.\",\"url\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf\",\"mainEntityOfPage\":{\"@id\":\"https://docs.keywordsai.co/documentation/products/gateway/advanced_features/upload_pdf#webpage\"},\"image\":\"https://docs.keywordsai.co/logo.svg\",\"dateModified\":\"2026-01-28T19:11:54.638Z\",\"publisher\":{\"@id\":\"https://docs.keywordsai.co/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.keywordsai.co#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/documentation/products/gateway/advanced_features/upload_pdf.md","siteName":"Docs","nav":{"global":null,"tabs":[{"tab":"Documentation","groups":[{"group":"Get started","pages":[{"title":"Overview","sidebarTitle":"Overview","href":"/get-started/overview"},{"group":"Quickstart","pages":[{"title":"Logging via API","href":"/get-started/quickstart/logging"},{"title":"Agent tracing","href":"/get-started/quickstart/tracing"},{"title":"AI gateway","href":"/get-started/quickstart/gateway"},{"title":"Create a prompt","href":"/get-started/quickstart/prompt_management"},{"title":"Evaluations","href":"/get-started/quickstart/evaluation"}]},{"title":"Observability data model","href":"/get-started/observability_data_model"}]},{"group":"Features","pages":[{"group":"Observability","pages":[{"title":"Metrics","href":"/documentation/products/dashboard/metrics"},{"title":"Views","href":"/documentation/products/dashboard/views"},{"group":"Logs","pages":[{"title":"Quickstart","url":"https://docs.keywordsai.co/get-started/quickstart/logging","href":"/documentation/products/logs/quickstart"},{"title":"Pass Keywords AI parameters","href":"/documentation/products/logs/configuration/pass_keywordsai_parameters"},{"title":"Custom properties","href":"/documentation/products/logs/configuration/custom_properties"},{"title":"Log prompt variables","href":"/documentation/products/logs/log_variables"},{"title":"Log tool calls","href":"/documentation/products/logs/log_tool_calls"},{"title":"Log Images","href":"/documentation/products/logs/log_images"},{"title":"Log thinking blocks","href":"/documentation/products/logs/log_thinking"},{"title":"Log embedding models","href":"/documentation/products/logs/embedding_logging"},{"title":"Save log as prompt","href":"/documentation/products/logs/save_log_to_prompt"},{"title":"Threads","href":"/documentation/products/logs/configuration/threads"},{"title":"Export logs","href":"/documentation/products/logs/export_logs"},{"title":"Group logs","href":"/documentation/products/logs/configuration/group_logs"},{"title":"Custom model","href":"/documentation/products/logs/custom_model"},{"title":"Sharing","href":"/documentation/products/logs/sharing"}]},{"group":"Traces","pages":[{"title":"Quickstart","url":"https://docs.keywordsai.co/get-started/quickstart/tracing","href":"/documentation/products/traces/quickstart"},{"title":"Decorators","href":"/documentation/products/traces/decorators"},{"title":"Pass Keywords AI parameters","href":"/documentation/products/traces/configuration/pass_keywordsai_parameters"},{"title":"Group traces","href":"/documentation/products/traces/configuration/group_traces"},{"title":"Customer identifier","href":"/documentation/products/traces/configuration/customer_identifier"},{"title":"Override span input \u0026 output","href":"/documentation/products/traces/override-span-input-output"},{"title":"Ingest traces from logs","href":"/documentation/products/traces/logs_to_trace"}]},{"group":"Users","pages":[{"title":"Enable user analytics","href":"/documentation/products/users/customer-identifier"},{"title":"Rate limit for users","href":"/documentation/products/users/user_rate_limit"},{"title":"Set budget for users","href":"/documentation/products/users/user-budget"}]}]},{"group":"Prompt management","pages":[{"title":"Quickstart","url":"https://docs.keywordsai.co/get-started/quickstart/prompt_management","href":"/documentation/products/prompt_management/quickstart"},{"title":"Prompt playground","sidebarTitle":"Prompt playground","href":"/documentation/products/prompt_management/model_playground"},{"group":"Create prompts","pages":[{"title":"Create a prompt","href":"/documentation/products/prompt_management/creating_prompts/create_prompt"},{"title":"JSON schema","href":"/documentation/products/prompt_management/creating_prompts/json_schema"},{"title":"Streaming","href":"/documentation/products/prompt_management/creating_prompts/streaming"},{"title":"Jinja support","href":"/documentation/products/prompt_management/creating_prompts/jinja_support"},{"title":"Create a prompt via API","href":"/documentation/products/prompt_management/creating_prompts/manage_prompt_api"}]},{"title":"Version control","href":"/documentation/products/prompt_management/management_collaboration/version_control"},{"group":"Use prompt in code","pages":[{"title":"Use prompt in gateway","href":"/documentation/products/prompt_management/use_prompt_in_code/use_prompt_in_llms"},{"title":"Use prompt in logging","href":"/documentation/products/prompt_management/use_prompt_in_code/prompt_logging"}]},{"title":"Team collaboration","href":"/documentation/products/prompt_management/management_collaboration/team_collaboration"}]},{"group":"Evals","pages":[{"group":"Evaluators","pages":[{"title":"Set up an LLM evaluator","href":"/documentation/products/evaluation/llm-evals/llm-evaluator"},{"title":"Run LLM evals in code","href":"/documentation/products/evaluation/llm-evals/run-evaluator-code"},{"title":"Run LLM evals via UI","href":"/documentation/products/evaluation/llm-evals/run-evaluator-ui"},{"title":"Set up human evaluators","href":"/documentation/products/evaluation/human-evals/human-evals-setup"},{"title":"Send human evals via API","href":"/documentation/products/evaluation/human-evals/human-annotation"}]},{"group":"Datasets","pages":[{"title":"Create datasets via API","href":"/documentation/products/dataset/via_api"},{"title":"Create datasets in the UI","href":"/documentation/products/dataset/via_ui"}]},{"group":"Testsets","pages":[{"title":"Add test cases from logs","href":"/documentation/products/evaluation/experiments/testsets"},{"title":"Upload a testset","href":"/documentation/products/evaluation/experiments/upload-testsets"}]},{"group":"Experiments","pages":[{"title":"Run experiments via UI","href":"/documentation/products/evaluation/experiments/experiments"},{"title":"Run experiments with images","href":"/documentation/products/evaluation/experiments/experiments-images"}]},{"group":"Experiments V2 (Beta)","pages":[{"title":"Create Experiments in the UI","href":"/documentation/products/experiments_v2/via_ui"},{"title":"Run Experiments via API","href":"/documentation/products/experiments_v2/api-tutorial"}]}]},{"group":"LLM Gateway","pages":[{"title":"AI gateway","href":"/get-started/quickstart/gateway"},{"title":"Supported models","href":"/documentation/products/gateway/configuration/models"},{"title":"Load balancing","href":"/documentation/products/gateway/traffic_management/load-balancing"},{"title":"Retries","href":"/documentation/products/gateway/traffic_management/retries"},{"title":"Fallback models","href":"/documentation/products/gateway/traffic_management/fallbacks"},{"title":"Rate limit","href":"/documentation/products/gateway/traffic_management/rate_limit"},{"group":"Caches","pages":[{"title":"Caches","href":"/documentation/products/gateway/performance_optimization/caches"},{"title":"Prompt caching","href":"/documentation/products/gateway/performance_optimization/prompt-caching"}]},{"title":"Function calling","href":"/documentation/products/gateway/advanced_features/function_calling"},{"title":"Enable thinking","description":"How to enable thinking mode for supported models","href":"/documentation/products/gateway/advanced_features/thinking"},{"title":"Upload PDF","href":"/documentation/products/gateway/advanced_features/upload_pdf"},{"title":"Upload image","description":"Learn how to upload image variables through Keywords AI gateway.","href":"/documentation/products/gateway/advanced_features/upload_image"},{"title":"Disable logging","href":"/documentation/products/gateway/monitoring_analysis/disable_logging"}]},{"group":"Notifications","pages":[{"title":"Alerts \u0026 Warnings","href":"/documentation/products/notifications/subscribe_alerts"},{"title":"Webhooks","href":"/documentation/products/notifications/webhooks"}]},{"group":"Automations (Beta)","pages":[{"title":"Monitoring","href":"/documentation/products/automation/quickstart"},{"title":"Online evals","href":"/documentation/products/automation/quickstart_online_eval"}]}]},{"group":"Admin","pages":[{"title":"Keywords API keys","href":"/documentation/admin/keywords_api_keys"},{"title":"LLM provider keys","href":"/documentation/admin/llm_provider_keys"},{"group":"Team management","pages":[{"title":"Create a new team","href":"/documentation/admin/team_management/create_a_new_team"}]}]},{"group":"Security","pages":[{"title":"Trust center","href":"/documentation/security/trust_center"},{"title":"SOC II","href":"/documentation/security/socii"},{"title":"HIPAA Compliance","href":"/documentation/security/hipaa"},{"title":"GDPR","href":"/documentation/security/gdpr"},{"title":"Architecture review","href":"/documentation/security/architecture_review"},{"title":"Security FAQ","href":"/documentation/security/security-qa"}]},{"group":"Resources","pages":[{"title":"Model Context Protocol (MCP)","href":"/documentation/resources/mcp"},{"title":"What is LLM monitoring?","href":"/documentation/resources/what-is-llm-observability-and-monitoring"},{"title":"Automatic retries","href":"/documentation/resources/automatic-retries"},{"title":"How streaming works","href":"/documentation/resources/streaming"},{"title":"Error handling","href":"/documentation/resources/error-handling"},{"title":"API rate limits","href":"/documentation/resources/api-rate-limits"},{"title":"Respan","href":"/documentation/resources/respan"}]},{"group":"Help \u0026 Community","pages":[{"title":"Support","href":"/documentation/support/support"},{"title":"Feedback","href":"/documentation/support/feedback"},{"title":"Status","href":"/documentation/support/status"}]}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integration/overview"}]},{"tab":"API reference","pages":[{"title":"API reference","href":"/api-endpoints/observe/logs/request-logging-endpoint"}]},{"tab":"SDKs","pages":[{"title":"SDKs","href":"/tracing-sdk/quickstart"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Upload PDF - Docs","deploymentId":"dpl_6UE2cqB47X6P7P3F2hD3UphW6ijc","buildId":"dpl_6UE2cqB47X6P7P3F2hD3UphW6ijc","dynamics":[],"chunks":[]}