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

# Upload File

> Upload a file for use with AI chat completions.

This endpoint allows uploading documents or images that can later be referenced in chat completion requests via the metadata.files parameter.


<RequestExample>
  ```bash cURL theme={null}
  curl "https://customerName.ambersearch.de/api/beta/files/upload?type=document" \
  -H "Authorization: Bearer ambrs-exampletoken" \
  -F file="@myfile.pdf"
  ```

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

  response = requests.posts(
      "https://customerName.ambersearch.de/api/beta/files/upload?type=document",
      headers = {
          "Authorization": "Bearer ambrs-exampletoken"
      },
      files = {
          "file": open("myfile.pdf", "rb")
      }
  )
  print(response.json())
  ```

  ```javascript Javascript theme={null}
  const axios = require("axios");

  axios
      .post("https://customerName.ambersearch.de/api/beta/files/upload?type=document", {
          headers: {
              Authorization: "Bearer ambrs-exampletoken",
          },
          files: {
              file: fs.createReadStream("myfile.pdf"),
          },
      })
      .then((res) => console.log(res.data));
  ```
</RequestExample>


## OpenAPI

````yaml post /api/beta/files/upload
openapi: 3.1.0
info:
  title: amber
  version: v0.1.46
servers:
  - url: https://{customerDomain}.ambersearch.de
    variables:
      customerDomain:
        default: customerDomain
security: []
paths:
  /api/beta/files/upload:
    post:
      tags:
        - Public REST API
      summary: Upload File Public Api
      description: >-
        Upload a file for use with AI chat completions.


        This endpoint allows uploading documents or images that can later be
        referenced

        in chat completion requests via the metadata.files parameter.


        ## Request


        Send a multipart/form-data request with:

        - `type`: The type of file (document or image)

        - `file`: The file to upload


        ## Returns


        A response containing file metadata:


        ```json

        {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "type": "document",
            "name": "example.pdf",
            "created_at": "2024-01-15T10:30:00Z",
            "size": 1024
        }

        ```


        ## Usage with Chat Completions


        After uploading, use the returned file ID in chat completion requests:


        ```json

        {
            "model": "azure-gpt-5",
            "metadata": {
                "files": ["550e8400-e29b-41d4-a716-446655440000"]
            },
            "messages": [...]
        }

        ```


        ## Raises


        - **HTTPException 415**: If the file type is not supported

        - **HTTPException 422**: If the document is too large

        - **HTTPException 500**: If file processing fails
      operationId: Upload File
      parameters:
        - name: type
          in: query
          required: true
          schema:
            enum:
              - document
              - image
            type: string
            description: |-
              The type of file being uploaded.

                      **Possible values:**
                      * `document` - Document files (PDF, Word, etc.)
                      * `image` - Image files (PNG, JPEG, etc.)
            examples:
              - document
            title: Type
          description: |-
            The type of file being uploaded.

                    **Possible values:**
                    * `document` - Document files (PDF, Word, etc.)
                    * `image` - Image files (PNG, JPEG, etc.)
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_Upload_File'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadedFileResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - Bearer: []
components:
  schemas:
    Body_Upload_File:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
          description: The file to upload
      type: object
      required:
        - file
      title: Body_Upload File
    UploadedFileResponse:
      properties:
        source:
          type: string
          const: uploaded_file
          title: Source
          default: uploaded_file
        id:
          type: string
          title: Id
        type:
          $ref: '#/components/schemas/FileType-Output'
        name:
          type: string
          title: Name
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
        size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Size
      type: object
      required:
        - id
        - type
        - name
      title: UploadedFileResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FileType-Output:
      type: string
      enum:
        - document
        - image
      title: FileType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````