Method: media.upload

Uploads a local file to create a File resource.

Refer to this colab for an example of how to use the upload service

HTTP request

  • Upload URI, for media upload requests:
    POST https://generativelanguage.googleapis.com/upload/v1beta/files
  • Metadata URI, for metadata-only requests:
    POST https://generativelanguage.googleapis.com/v1beta/files

The URL uses gRPC Transcoding syntax.

Request body

The request body contains data with the following structure:

JSON representation
{
  "file": {
    object (File)
  }
}
Fields
file

object (File)

Optional. Metadata for the file to create.

Response body

Response for media.upload.

If successful, the response body contains data with the following structure:

JSON representation
{
  "file": {
    object (File)
  }
}
Fields
file

object (File)

Metadata for the created file.