SPB Git

Repository Public

files.md 9.0 KB 492 lines markdown

1# Files23> 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## Create container file67**post** `/containers/{container_id}/files`89Create a Container File1011You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.1213### Path Parameters1415- `container_id: string`1617### Body Parameters1819- `file: optional string`2021  The File object (not file name) to be uploaded.2223- `file_id: optional string`2425  Name of the file to create.2627### Returns2829- `id: string`3031  Unique identifier for the file.3233- `bytes: number`3435  Size of the file in bytes.3637- `container_id: string`3839  The container this file belongs to.4041- `created_at: number`4243  Unix timestamp (in seconds) when the file was created.4445- `object: string`4647  The type of this object (`container.file`).4849- `path: string`5051  Path of the file in the container.5253- `source: string`5455  Source of the file (e.g., `user`, `assistant`).5657### Example5859```http60curl https://api.openai.com/v1/containers/$CONTAINER_ID/files \61    -H 'Content-Type: application/json' \62    -H "Authorization: Bearer $OPENAI_API_KEY" \63    -d '{}'64```6566#### Response6768```json69{70  "id": "id",71  "bytes": 0,72  "container_id": "container_id",73  "created_at": 0,74  "object": "object",75  "path": "path",76  "source": "source"77}78```7980### Example8182```http83curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \84  -H "Authorization: Bearer $OPENAI_API_KEY" \85  -F file="@example.txt"86```8788#### Response8990```json91{92  "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",93  "object": "container.file",94  "created_at": 1747848842,95  "bytes": 880,96  "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",97  "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",98  "source": "user"99}100```101102## Delete a container file103104**delete** `/containers/{container_id}/files/{file_id}`105106Delete Container File107108### Path Parameters109110- `container_id: string`111112- `file_id: string`113114### Example115116```http117curl https://api.openai.com/v1/containers/$CONTAINER_ID/files/$FILE_ID \118    -X DELETE \119    -H "Authorization: Bearer $OPENAI_API_KEY"120```121122### Example123124```http125curl -X DELETE https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863/files/cfile_682e0e8a43c88191a7978f477a09bdf5 \126  -H "Authorization: Bearer $OPENAI_API_KEY"127```128129#### Response130131```json132{133    "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",134    "object": "container.file.deleted",135    "deleted": true136}137```138139## List container files140141**get** `/containers/{container_id}/files`142143List Container files144145### Path Parameters146147- `container_id: string`148149### Query Parameters150151- `after: optional string`152153  A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.154155- `limit: optional number`156157  A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.158159- `order: optional "asc" or "desc"`160161  Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.162163  - `"asc"`164165  - `"desc"`166167### Returns168169- `data: array of object { id, bytes, container_id, 4 more }`170171  A list of container files.172173  - `id: string`174175    Unique identifier for the file.176177  - `bytes: number`178179    Size of the file in bytes.180181  - `container_id: string`182183    The container this file belongs to.184185  - `created_at: number`186187    Unix timestamp (in seconds) when the file was created.188189  - `object: string`190191    The type of this object (`container.file`).192193  - `path: string`194195    Path of the file in the container.196197  - `source: string`198199    Source of the file (e.g., `user`, `assistant`).200201- `first_id: string`202203  The ID of the first file in the list.204205- `has_more: boolean`206207  Whether there are more files available.208209- `last_id: string`210211  The ID of the last file in the list.212213- `object: "list"`214215  The type of object returned, must be 'list'.216217  - `"list"`218219### Example220221```http222curl https://api.openai.com/v1/containers/$CONTAINER_ID/files \223    -H "Authorization: Bearer $OPENAI_API_KEY"224```225226#### Response227228```json229{230  "data": [231    {232      "id": "id",233      "bytes": 0,234      "container_id": "container_id",235      "created_at": 0,236      "object": "object",237      "path": "path",238      "source": "source"239    }240  ],241  "first_id": "first_id",242  "has_more": true,243  "last_id": "last_id",244  "object": "list"245}246```247248### Example249250```http251curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \252  -H "Authorization: Bearer $OPENAI_API_KEY"253```254255#### Response256257```json258{259    "object": "list",260    "data": [261        {262            "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",263            "object": "container.file",264            "created_at": 1747848842,265            "bytes": 880,266            "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",267            "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",268            "source": "user"269        }270    ],271    "first_id": "cfile_682e0e8a43c88191a7978f477a09bdf5",272    "has_more": false,273    "last_id": "cfile_682e0e8a43c88191a7978f477a09bdf5"274}275```276277## Retrieve container file278279**get** `/containers/{container_id}/files/{file_id}`280281Retrieve Container File282283### Path Parameters284285- `container_id: string`286287- `file_id: string`288289### Returns290291- `id: string`292293  Unique identifier for the file.294295- `bytes: number`296297  Size of the file in bytes.298299- `container_id: string`300301  The container this file belongs to.302303- `created_at: number`304305  Unix timestamp (in seconds) when the file was created.306307- `object: string`308309  The type of this object (`container.file`).310311- `path: string`312313  Path of the file in the container.314315- `source: string`316317  Source of the file (e.g., `user`, `assistant`).318319### Example320321```http322curl https://api.openai.com/v1/containers/$CONTAINER_ID/files/$FILE_ID \323    -H "Authorization: Bearer $OPENAI_API_KEY"324```325326#### Response327328```json329{330  "id": "id",331  "bytes": 0,332  "container_id": "container_id",333  "created_at": 0,334  "object": "object",335  "path": "path",336  "source": "source"337}338```339340### Example341342```http343curl https://api.openai.com/v1/containers/container_123/files/file_456 \344  -H "Authorization: Bearer $OPENAI_API_KEY"345```346347#### Response348349```json350{351    "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",352    "object": "container.file",353    "created_at": 1747848842,354    "bytes": 880,355    "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",356    "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",357    "source": "user"358}359```360361## Domain Types362363### File Create Response364365- `FileCreateResponse object { id, bytes, container_id, 4 more }`366367  - `id: string`368369    Unique identifier for the file.370371  - `bytes: number`372373    Size of the file in bytes.374375  - `container_id: string`376377    The container this file belongs to.378379  - `created_at: number`380381    Unix timestamp (in seconds) when the file was created.382383  - `object: string`384385    The type of this object (`container.file`).386387  - `path: string`388389    Path of the file in the container.390391  - `source: string`392393    Source of the file (e.g., `user`, `assistant`).394395### File List Response396397- `FileListResponse object { id, bytes, container_id, 4 more }`398399  - `id: string`400401    Unique identifier for the file.402403  - `bytes: number`404405    Size of the file in bytes.406407  - `container_id: string`408409    The container this file belongs to.410411  - `created_at: number`412413    Unix timestamp (in seconds) when the file was created.414415  - `object: string`416417    The type of this object (`container.file`).418419  - `path: string`420421    Path of the file in the container.422423  - `source: string`424425    Source of the file (e.g., `user`, `assistant`).426427### File Retrieve Response428429- `FileRetrieveResponse object { id, bytes, container_id, 4 more }`430431  - `id: string`432433    Unique identifier for the file.434435  - `bytes: number`436437    Size of the file in bytes.438439  - `container_id: string`440441    The container this file belongs to.442443  - `created_at: number`444445    Unix timestamp (in seconds) when the file was created.446447  - `object: string`448449    The type of this object (`container.file`).450451  - `path: string`452453    Path of the file in the container.454455  - `source: string`456457    Source of the file (e.g., `user`, `assistant`).458459# Content460461## Retrieve container file content462463**get** `/containers/{container_id}/files/{file_id}/content`464465Retrieve Container File Content466467### Path Parameters468469- `container_id: string`470471- `file_id: string`472473### Example474475```http476curl https://api.openai.com/v1/containers/$CONTAINER_ID/files/$FILE_ID/content \477    -H "Authorization: Bearer $OPENAI_API_KEY"478```479480### Example481482```http483curl https://api.openai.com/v1/containers/container_123/files/cfile_456/content \484  -H "Authorization: Bearer $OPENAI_API_KEY"485```486487#### Response488489```json490<binary content of the file>491```492
Files main
Menu

Theme