Skip to main content
POST
/
genai
/
upload
/
v1beta
/
files
Upload file (Gemini format)
curl --request POST \
  --url http://localhost:8080/genai/upload/v1beta/files \
  --header 'Content-Type: multipart/form-data' \
  --form file='@example-file' \
  --form 'metadata={
  "file": {
    "displayName": "<string>"
  }
}'
{
  "file": {
    "name": "<string>",
    "displayName": "<string>",
    "mimeType": "<string>",
    "sizeBytes": "<string>",
    "createTime": "2023-11-07T05:31:56Z",
    "updateTime": "2023-11-07T05:31:56Z",
    "expirationTime": "2023-11-07T05:31:56Z",
    "sha256Hash": "<string>",
    "uri": "<string>",
    "state": "STATE_UNSPECIFIED",
    "error": {
      "code": 123,
      "message": "<string>"
    },
    "videoMetadata": {
      "videoDuration": "<string>"
    }
  }
}

Body

multipart/form-data

Multipart upload for Gemini Files API. Send two parts: - "metadata": JSON object {"file": {"displayName": ""}} - "file": binary content Note: Direct file content download is not supported by Gemini Files API. Use the file.uri field from the response to access the file.

file
file
required
metadata
object

JSON metadata part; see encoding at the path for contentType application/json.

Response

Successful response

file
object