---
title: "Upload Gemini file"
method: POST
path: "/upload/v1beta/files"
tags: ["Gemini Resources"]
---

# Upload Gemini file

`POST /upload/v1beta/files`

## Request

- Base URL: `https://api.tokenlab.sh`
- URL: `https://api.tokenlab.sh/upload/v1beta/files`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-goog-api-key`

Uploads bytes or starts a resumable upload. For resumable start, send metadata and read X-Goog-Upload-URL. Continue only at that returned URL. The upload URL grants access to that upload, expires after one hour, and must be kept private. Resources can only be read, referenced, changed, or deleted in their owning Workspace. Missing, expired, or inaccessible resources return a Gemini-format error.

## Query parameters

- `key` string

## Headers

- `Idempotency-Key` string
- `X-Goog-Upload-Protocol` string
- `X-Goog-Upload-Command` string
- `X-Goog-Upload-Header-Content-Length` string
- `X-Goog-Upload-Header-Content-Type` string

## Request body

- GeminiFileCreateRequest: Gemini file metadata request. Supported fields and values are validated by the service. File bytes are uploaded through /upload/v1beta/files.
  - `file` GeminiFileResource: A Gemini file in the current Workspace. Fields are returned when available.
    - `name` string: File resource name such as files/{fileId}.
    - `displayName` string: Human-readable file name.
    - `mimeType` string: Media MIME type.
    - `sizeBytes` string: File byte size as a decimal string.
    - `uri` string: File URI to use in Gemini content parts.
    - `state` string: Processing state reported by the service. Wait until the file is ready before generation.
    - `createTime` string, date-time
    - `updateTime` string, date-time
    - `expirationTime` string, date-time
    - `error` object

## Response `200`

Success

- object
  - `file` GeminiFileResource: A Gemini file in the current Workspace. Fields are returned when available.
    - `name` string: File resource name such as files/{fileId}.
    - `displayName` string: Human-readable file name.
    - `mimeType` string: Media MIME type.
    - `sizeBytes` string: File byte size as a decimal string.
    - `uri` string: File URI to use in Gemini content parts.
    - `state` string: Processing state reported by the service. Wait until the file is ready before generation.
    - `createTime` string, date-time
    - `updateTime` string, date-time
    - `expirationTime` string, date-time
    - `error` object

## Other responses

- `400`: Gemini-format resource error
- `401`: Gemini-format resource error
- `403`: Gemini-format resource error
- `404`: Gemini-format resource error
- `409`: Gemini-format resource error
- `429`: Gemini-format resource error
- `502`: Gemini-format resource error
- `503`: Gemini-format resource error

---

[API](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway.md) · [All operations](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/revisions/3208bfbcda22?raw)
