Repository Public
1# Sending and returning files with GPT Actions23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Sending files67POST requests can include up to ten files (including DALL-E generated images) from the conversation. They will be sent as URLs which are valid for five minutes.89For files to be part of your POST request, the parameter must be named `openaiFileIdRefs` and the description should explain to the model the type and quantity of the files which your API is expecting.1011The `openaiFileIdRefs` parameter will be populated with an array of JSON objects. Each object contains:1213- `name` The name of the file. This will be an auto generated name when created by DALL-E.14- `id` A stable identifier for the file.15- `mime_type` The mime type of the file. For user uploaded files this is based on file extension.16- `download_link` The URL to fetch the file which is valid for five minutes.1718Here’s an example of an `openaiFileIdRefs` array with two elements:1920```json21[22 {23 "name": "dalle-Lh2tg7WuosbyR9hk",24 "id": "file-XFlOqJYTPBPwMZE3IopCBv1Z",25 "mime_type": "image/webp",26 "download_link": "https://files.oaiusercontent.com/file-XFlOqJYTPBPwMZE3IopCBv1Z?se=2024-03-11T20%3A29%3A52Z&sp=r&sv=2021-08-06&sr=b&rscc=max-age%3D31536000%2C%20immutable&rscd=attachment%3B%20filename%3Da580bae6-ea30-478e-a3e2-1f6c06c3e02f.webp&sig=ZPWol5eXACxU1O9azLwRNgKVidCe%2BwgMOc/TdrPGYII%3D"27 },28 {29 "name": "2023 Benefits Booklet.pdf",30 "id": "file-s5nX7o4junn2ig0J84r8Q0Ew",31 "mime_type": "application/pdf",32 "download_link": "https://files.oaiusercontent.com/file-s5nX7o4junn2ig0J84r8Q0Ew?se=2024-03-11T20%3A29%3A52Z&sp=r&sv=2021-08-06&sr=b&rscc=max-age%3D299%2C%20immutable&rscd=attachment%3B%20filename%3D2023%2520Benefits%2520Booklet.pdf&sig=Ivhviy%2BrgoyUjxZ%2BingpwtUwsA4%2BWaRfXy8ru9AfcII%3D"33 }34]35```3637Actions can include files uploaded by the user, images generated by DALL-E, and files created by Code Interpreter.3839### OpenAPI Example4041```yaml42/createWidget:43 post:44 operationId: createWidget45 summary: Creates a widget based on an image.46 description: Uploads a file reference using its file id. This file should be an image created by DALL·E or uploaded by the user. JPG, WEBP, and PNG are supported for widget creation.47 requestBody:48 required: true49 content:50 application/json:51 schema:52 type: object53 properties:54 openaiFileIdRefs:55 type: array56 items:57 type: string58```5960While this schema shows `openaiFileIdRefs` as being an array of type `string`, at runtime this will be populated with an array of JSON objects as previously shown.6162## Returning files6364Requests may return up to 10 files. Each file may be up to 10 MB and cannot be an image or video.6566These files will become part of the conversation similarly to if a user uploaded them, meaning they may be made available to code interpreter, file search, and sent as part of subsequent action invocations. In the web app users will see that the files have been returned and can download them.6768To return files, the body of the response must contain an `openaiFileResponse` parameter. This parameter must always be an array and must be populated in one of two ways.6970### Inline option7172Each element of the array is a JSON object which contains:7374- `name` The name of the file. This will be visible to the user.75- `mime_type` The MIME type of the file. This is used to determine eligibility and which features have access to the file.76- `content` The base64 encoded contents of the file.7778Here’s an example of an openaiFileResponse array with two elements:7980```json81[82 {83 "name": "example_document.pdf",84 "mime_type": "application/pdf",85 "content": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29kZT4+CnN0cmVhbQpHhD93PQplbmRzdHJlYW0KZW5kb2JqCg=="86 },87 {88 "name": "sample_spreadsheet.csv",89 "mime_type": "text/csv",90 "content": "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="91 }92]93```9495OpenAPI example9697```yaml98/papers:99 get:100 operationId: findPapers101 summary: Retrieve PDFs of relevant academic papers.102 description: Provided an academic topic, up to five relevant papers will be returned as PDFs.103 parameters:104 - in: query105 name: topic106 required: true107 schema:108 type: string109 description: The topic the papers should be about.110 responses:111 "200":112 description: Zero to five academic paper PDFs113 content:114 application/json:115 schema:116 type: object117 properties:118 openaiFileResponse:119 type: array120 items:121 type: object122 properties:123 name:124 type: string125 description: The name of the file.126 mime_type:127 type: string128 description: The MIME type of the file.129 content:130 type: string131 format: byte132 description: The content of the file in base64 encoding.133```134135### URL option136137Each element of the array is a URL referencing a file to be downloaded. The headers `Content-Disposition` and `Content-Type` must be set such that a file name and MIME type can be determined. The name of the file will be visible to the user. The MIME type of the file determines eligibility and which features have access to the file.138139There is a 10 second timeout for fetching each file.140141Here’s an example of an `openaiFileResponse` array with two elements:142143```json144[145 "https://example.com/f/dca89f18-16d4-4a65-8ea2-ededced01646",146 "https://example.com/f/01fad6b0-635b-4803-a583-0f678b2e6153"147]148```149150Here’s an example of the required headers for each URL:151152```153Content-Type: application/pdf154Content-Disposition: attachment; filename="example_document.pdf"155```156157OpenAPI example158159```yaml160/papers:161 get:162 operationId: findPapers163 summary: Retrieve PDFs of relevant academic papers.164 description: Provided an academic topic, up to five relevant papers will be returned as PDFs.165 parameters:166 - in: query167 name: topic168 required: true169 schema:170 type: string171 description: The topic the papers should be about.172 responses:173 '200':174 description: Zero to five academic paper PDFs175 content:176 application/json:177 schema:178 type: object179 properties:180 openaiFileResponse:181 type: array182 items:183 type: string184 format: uri185 description: URLs to fetch the files.186```