# Upload agent file

`POST /v1/projects/{project}/agents/{agent}/files`, operation `agents.UploadAgentFile`

Uploads a file to an agent, for a message to attach by its name. The body is the file, as it is, of the media type that Content-Type names; without one, or with application/octet-stream, kosem tells the type from the content.

A file that no message attaches within a day is deleted; the others are kept with the agent. The agent's model reads an image, scaled down if it is larger than models read, and a PDF of at most 10 MiB, and of other files a description, by which the agent's tools open them. A file is at most 50 MiB, and an agent's files 1 GiB all told.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `project` | path | Yes | `string` | The project's ID. |
| `agent` | path | Yes | `string` | The agent's ID. |
| `filename` | query | Yes | `string` | The file's name, without a directory. |

## Request body

Content-Type: `application/octet-stream` (required)

Schema: `string (binary)`.

## Responses

### 201

Created

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `createTime` | `string (date-time)` | Yes | When it was uploaded. |
| `creator` | `string` | Yes | Who uploaded it, such as user:usr_…. |
| `filename` | `string` | Yes | Its file name. |
| `height` | `integer (int32)` | No | An image's height, in pixels. |
| `mediaType` | `string` | Yes | Its media type, such as image/png or application/pdf. |
| `modelReads` | `string` | Yes | What the agent's model reads of the file in a message: CONTENT, the file itself, as an image or a document, which models that read neither get a placeholder for; or DESCRIPTION, its name, media type, size and ID alone, by which the agent's tools open it. Values: `CONTENT`, `DESCRIPTION`. |
| `name` | `string` | Yes | Resource name, projects/{project_id}/agents/{agent_id}/files/{file_id}, by which a message's file part attaches it. |
| `sha256` | `string` | Yes | The SHA-256 of its content, in hexadecimal. |
| `sizeBytes` | `integer (int64)` | Yes | Its size, in bytes. |
| `width` | `integer (int32)` | No | An image's width, in pixels. |

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.