# File Input API throws error for PDF file which is Base64-encoded

**URL:** <https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970>\
**Category:** Bugs\
**Tags:** pdf, file-uploads\
**Created:** [March 14, 2025, 9:34am UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970 "2025-03-14T09:34:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudarsangp](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sudarsangp](https://community.openai.com/u/sudarsangp)\
**Post date:** [March 14, 2025, 9:34am UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/1 "2025-03-14T09:34:34Z")

</div>

Hello Team,

[Reference documentation](https://platform.openai.com/docs/guides/pdf-files?api-mode=chat&lang=javascript#base64-encoded-files)

> You can send PDF file inputs as Base64-encoded inputs as well.

When I try the example provided, it results in error:

> 400 Missing required parameter: ‘messages[1].content[0].file.file\_id’

I am using npm openai library `4.77.3`

Has anyone tried this?

---

<div class="post-metadata">

**Author:** ![mazzocchitomi](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mazzocchitomi/32/564704_2.png) [@mazzocchitomi](https://community.openai.com/u/mazzocchitomi)\
**Post date:** [March 14, 2025, 2:53pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/2 "2025-03-14T14:53:58Z")

</div>

I am experiencing the same error.

---

<div class="post-metadata">

**Author:** ![dev.tringuyen](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dev.tringuyen/32/564775_2.png) [@dev.tringuyen](https://community.openai.com/u/dev.tringuyen)\
**Post date:** [March 14, 2025, 6:29pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/3 "2025-03-14T18:29:18Z")

</div>

I got same error, hope they fix as soon as posible

---

<div class="post-metadata">

**Author:** ![vitorbarbosa19](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/vitorbarbosa19/32/514795_2.png) [@vitorbarbosa19](https://community.openai.com/u/vitorbarbosa19)\
**Post date:** [March 18, 2025, 2:46pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/4 "2025-03-18T14:46:15Z")

</div>

I’ve opened an issue. You can check it here [400 Missing required parameter: 'messages[1].content[0].file.file\_id' · Issue #1389 · openai/openai-node · GitHub](https://github.com/openai/openai-node/issues/1389)  
The fix is simply to rename `file_name` to `filename` and add a // @ts-expect-error line above, to prevent the typescript error

 ![Screenshot 2025-03-18 at 11.45.38](https://us1.discourse-cdn.com/openai1/original/4X/e/3/d/e3dd7b52b3741c6919e522553737a1c1b2e7ca62.png)

---

<div class="post-metadata">

**Author:** ![edwinarbus](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/edwinarbus/32/455108_2.png) [@edwinarbus](https://community.openai.com/u/edwinarbus)\
**Post date:** [March 18, 2025, 4:36pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/5 "2025-03-18T16:36:24Z")

</div>

This is being fixed now — sorry for the issues!

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [March 18, 2025, 5:24pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/6 "2025-03-18T17:24:35Z")

</div>

Which “this”: SDK, documentation, API? Notation that some base64 fields instead take a data URL?

Here’s a deliberate discovery of what was working and non-matching docs:

> [@Base64 file not going through api](https://community.openai.com/t/base64-file-not-going-through-api/1144263/2):
>
> Here is a request body successfully fulfilled by the API Prompts Playground, including base64 of a PDF as file content part. Chat Completions POST https://api.openai.com/v1/chat/completions { "messages":[ { "role":"user", "content":[ { "type":"text", "text":"Summarize PDF" }, { "type":"file", "file":{ "file\_data":"data:application/pdf;base64,JVBERi0xLjUNJeLjz9MN...", "filename":"competion-…

* * *

Fine-tune vision-compatible models are also erroring out on image input that work on chat completions when employing Responses.

---

<div class="post-metadata">

**Author:** ![mike.mcgowan2020](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mike.mcgowan2020/32/305521_2.png) [@mike.mcgowan2020](https://community.openai.com/u/mike.mcgowan2020)\
**Post date:** [March 19, 2025, 12:56am UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/7 "2025-03-19T00:56:26Z")

</div>

I am also receiving a 400 error when using the correct OpenAI storage file ID of a previously uploaded file.

---

<div class="post-metadata">

**Author:** ![edwinarbus](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/edwinarbus/32/455108_2.png) [@edwinarbus](https://community.openai.com/u/edwinarbus)\
**Post date:** [March 19, 2025, 1:33am UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/8 "2025-03-19T01:33:11Z")

</div>

It was ultimately an issue with the SDK, which is now fixed. @dev.tringuyen @mazzocchitomi @sudarsangp can you try again?

---

<div class="post-metadata">

**Author:** ![sudarsangp](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sudarsangp](https://community.openai.com/u/sudarsangp)\
**Post date:** [March 20, 2025, 3:23pm UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/9 "2025-03-20T15:23:56Z")

</div>

I tried with npm openai library `4.87.4` and it works based on the docs.

---

<div class="post-metadata">

**Author:** ![jeffvpace](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/jeffvpace/32/741732_2.png) [@jeffvpace](https://community.openai.com/u/jeffvpace)\
**Post date:** [April 8, 2025, 6:19am UTC](https://community.openai.com/t/file-input-api-throws-error-for-pdf-file-which-is-base64-encoded/1142970/10 "2025-04-08T06:19:38Z")

</div>

@_j , Thanks for taking the time to provide a solution for this - been tearing my hair out, until now…
