File input in chat responses api

Is PDF only type of file accepted as part of chat responses api with base64 encoding or reference it by id?

API Error message says so but wonder how it works in chat when we can upload any file and it works so why it is not in API?

“Invalid input: Expected context stuffing file type to be a supported format: .pdf but got .txt.”

What are best ways of using text and json files as inputs?

1 Like

If have plain text, you can just enclose it in a suitable container. It can be its own user message before the prompt input to distinguish it as not being a typed-out user input needing direct action. (the reason for separate messages being that “text” type “content” parts are all just concatenated without any separation or even linefeed).

For example placement:

user:

`*automated input*`
The user has attached this file(s) content to the conversation for your understanding:
```api_documentation.txt
Responses API usage object example:
{
   "input_tokens": 1289,
   "input_tokens_details": {
      "cached_tokens": 0       # portion discounted by matching prior context window
   },
   "output_tokens": 685,
   "output_tokens_details": {
      "reasoning_tokens": 640  # portion billed that was unseen reasoning
   },
   "total_tokens": 1974
}
```
[end of api_documentation.txt]

---

```api_jailbreaks.txt
(more text from files)
```
[end of api_jailbreaks.txt]

user:

Summarize the files I uploaded to you.

That is similar internally to PDFs, which come with some explanation of what is being provided by OpenAI.