> ## Documentation Index
> Fetch the complete documentation index at: https://magica-adi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload files

> Send an image or video as a file. You do not need a public URL.

The product UI uploads through Transloadit with a signed-in session. The public API accepts the same files with your API key.

You can **upload and send in one request**, or **upload first** and pass `attachmentIds`.

## Upload and send

`POST /api/v1/completions` accepts `text` + `file` in one `multipart/form-data` request. Omit `chatId` for a new chat, or pass it to continue one.

```bash theme={null}
# New chat
curl -X POST "$BASE/api/v1/completions" \
  -H "Authorization: Bearer $GALAXY_API_KEY" \
  -F "text=What is in this photo?" \
  -F "file=@./photo.jpg;type=image/jpeg"

# Existing chat
curl -X POST "$BASE/api/v1/completions" \
  -H "Authorization: Bearer $GALAXY_API_KEY" \
  -F "chatId=$CHAT_ID" \
  -F "text=What is in this photo?" \
  -F "file=@./photo.jpg;type=image/jpeg"
```

## Upload only

`POST /api/v1/uploads` stores the file and returns an attachment id. It does **not** create a chat. Pass `chatId` only if you want the file attached to an existing chat.

```bash theme={null}
curl -X POST "$BASE/api/v1/uploads" \
  -H "Authorization: Bearer $GALAXY_API_KEY" \
  -F "file=@./photo.jpg;type=image/jpeg"
```

```json theme={null}
{
  "chatId": null,
  "attachments": [
    {
      "id": "…",
      "filename": "photo.jpg",
      "mimeType": "image/jpeg",
      "url": "https://…",
      "status": "COMPLETE"
    }
  ]
}
```

Then send with `{ "text": "…", "attachmentIds": ["that-id"] }`.

## Limits

* Images, video, and audio (same types as the product uploader)
* 20 MB per file, 8 files
* Server needs **S3** or **Transloadit**. Otherwise `503 UPLOADS_UNAVAILABLE`

`image_urls` still works when the file is already on the public web. You do not have to use a URL if you have the file.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.