> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gptproto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# google-file-upload (file upload north america)

> Upload files to Google Generative AI API (North America region)

This endpoint allows you to upload files for use with Google's Generative AI models in the North America region.

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api-na.gptproto.com/upload/v1beta/files' \
    --header 'x-goog-api-key: YOUR_API_KEY' \
    --form 'file=@"/path/to/your/file.pdf"'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-na.gptproto.com/upload/v1beta/files"
  headers = {
      "x-goog-api-key": "YOUR_API_KEY"
  }

  files = {
      "file": open("/path/to/your/file.pdf", "rb")
  }

  response = requests.post(url, headers=headers, files=files)
  result = response.json()
  print(result)
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api-na.gptproto.com/upload/v1beta/files";
  const formData = new FormData();
  formData.append("file", fileInput.files[0]);

  fetch(url, {
    method: "POST",
    headers: {
      "x-goog-api-key": "YOUR_API_KEY"
    },
    body: formData
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "fmt"
      "io"
      "mime/multipart"
      "net/http"
      "os"
  )

  func main() {
      url := "https://api-na.gptproto.com/upload/v1beta/files"

      file, _ := os.Open("/path/to/your/file.pdf")
      defer file.Close()

      body := &bytes.Buffer{}
      writer := multipart.NewWriter(body)
      part, _ := writer.CreateFormFile("file", "file.pdf")
      io.Copy(part, file)
      writer.Close()

      req, _ := http.NewRequest("POST", url, body)
      req.Header.Set("x-goog-api-key", "YOUR_API_KEY")
      req.Header.Set("Content-Type", writer.FormDataContentType())

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      responseBody, _ := io.ReadAll(resp.Body)
      fmt.Println(string(responseBody))
  }
  ```
</CodeGroup>

<CodeGroup>
  ```json 401 - Invalid signature theme={null}
  {
    "error": {
      "message": "Invalid signature",
      "type": "401"
    }
  }
  ```

  ```json 500 - Internal server error theme={null}
  {
    "error": {
      "message": "Internal server error",
      "type": "500"
    }
  }
  ```
</CodeGroup>

## Parameters

| Parameter | Type | Required | Default | Description        |
| --------- | ---- | -------- | ------- | ------------------ |
| `file`    | file | ✅ Yes    | -       | The file to upload |
