> ## AI Agent Context
> Get the complete documentation index at: https://aistudio.google.com/llms.txt
> Use this file to discover all available pages.
> For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt

# Using files

The Gemini API supports uploading media files separately from the prompt input, allowing your media to be reused across multiple requests and multiple prompts. For more details, check out the [Prompting with media](/docs/file-input-methods) guide.

## Methods  {% id="methods" %}

{% table %}
  * Method
  * HTTP request

  ---

  * [Getting a file](/api-reference/files/get-file)
  *     {% mark class="http-get" %}{% icon name="south_west" /%}`GET`{% /mark %} `/v1beta/files/{file}`

    Gets the metadata for the given [`File`](/api-reference/files#Resource:File).


  ---

  * [Listing files](/api-reference/files/list-files)
  *     {% mark class="http-get" %}{% icon name="south_west" /%}`GET`{% /mark %} `/v1beta/files`

    Lists the metadata for [`File`](/api-reference/files#Resource:File)s owned by the requesting project.


  ---

  * [Deleting a file](/api-reference/files/delete-file)
  *     {% mark class="http-delete" %}{% icon name="close" /%}`DELETE`{% /mark %} `/v1beta/files/{file}`

    Deletes the [`File`](/api-reference/files#Resource:File).


  ---

  * [Registering files](/api-reference/files/register-files)
  *     {% mark class="http-post" %}{% icon name="north_east" /%}`POST`{% /mark %} `/v1beta/files:register`

    Registers a Google Cloud Storage files with FileService.


  ---

  * [Creating a file](/api-reference/files/create-file)
  *     {% mark class="http-post" %}{% icon name="north_east" /%}`POST`{% /mark %} `/v1beta/files`

    Creates a [`File`](/api-reference/files#Resource:File).

{% /table %}

## Resources  {% id="resources" %}

### File  {% id="Resource:File" %}

A file uploaded to the API.

**Properties:**

{% section class="api-ref-property-list" %}
  {% details %}
  {% summary %}
  **metadata**: `Union type`

  Metadata for the File.

  {% /summary %}

  Union field `metadata` can be only one of the following:

  {% details %}
  {% summary %}
  **videoMetadata**: `VideoFileMetadata`

  Output only. Metadata for a video.

  {% /summary %}

  **videoDuration**: `string`

  Duration of the video.

  {% /details %}

  {% /details %}

  {% hr /%}

  **name**: `string`

  Immutable. Identifier. The [`File`](/api-reference/files#Resource:File) resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`

  {% hr /%}

  **displayName**: `string`

  Optional. The human-readable display name for the [`File`](/api-reference/files#Resource:File). The display name must be no more than 512 characters in length, including spaces. Example: "Welcome Image"

  {% hr /%}

  **mimeType**: `string`

  Output only. MIME type of the file.

  {% hr /%}

  **sizeBytes**: `string`

  Output only. Size of the file in bytes.

  {% hr /%}

  **createTime**: `string`

  Output only. The timestamp of when the [`File`](/api-reference/files#Resource:File) was created.

  {% hr /%}

  **updateTime**: `string`

  Output only. The timestamp of when the [`File`](/api-reference/files#Resource:File) was last updated.

  {% hr /%}

  **expirationTime**: `string`

  Output only. The timestamp of when the [`File`](/api-reference/files#Resource:File) will be deleted. Only set if the [`File`](/api-reference/files#Resource:File) is scheduled to expire.

  {% hr /%}

  **sha256Hash**: `string`

  Output only. SHA-256 hash of the uploaded bytes.

  {% hr /%}

  **uri**: `string`

  Output only. The uri of the [`File`](/api-reference/files#Resource:File).

  {% hr /%}

  **downloadUri**: `string`

  Output only. The download uri of the [`File`](/api-reference/files#Resource:File).

  {% hr /%}

  {% details %}
  {% summary %}
  **state**: `string enum`

  Output only. Processing state of the File.

  {% /summary %}

  Possible values:

  - `STATE_UNSPECIFIED`: The default value. This value is used if the state is omitted.
  - `PROCESSING`: File is being processed and cannot be used for inference yet.
  - `ACTIVE`: File is processed and available for inference.
  - `FAILED`: File failed processing.

  {% /details %}

  {% hr /%}

  {% details %}
  {% summary %}
  **source**: `string enum`

  Source of the File.

  {% /summary %}

  Possible values:

  - `SOURCE_UNSPECIFIED`: Used if source is not specified.
  - `UPLOADED`: Indicates the file is uploaded by the user.
  - `GENERATED`: Indicates the file is generated by Google.
  - `REGISTERED`: Indicates the file is a registered, i.e. a Google Cloud Storage file.

  {% /details %}

  {% hr /%}

  **error**: [`Status`](/api-reference/files#Resource:Status)

  Output only. Error status if File processing failed.

{% /section %}

## Data Models  {% id="data-models" %}

### Status  {% id="Resource:Status" %}

The [`Status`](/api-reference/files#Resource:Status) type defines a logical error model that is suitable for
different programming environments, including REST APIs and RPC APIs. It is
used by [gRPC](https://github.com/grpc). Each [`Status`](/api-reference/files#Resource:Status) message contains
three pieces of data: error code, error message, and error details.

You can find out more about this error model and how to work with it in the
[API Design Guide](https://cloud.google.com/apis/design/errors).

**Properties:**

{% section class="api-ref-property-list" %}
  **code**: `integer`

  The status code, which should be an enum value of google.rpc.Code.

  {% hr /%}

  **message**: `string`

  A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.

  {% hr /%}

  **details**: `object array`

  A list of messages that carry the error details. There is a common set of message types for APIs to use.

{% /section %}

