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

# HIPAA AI Gateway

<Warning>
  Before call make sure that HIPAA AI Gateway feature enabled on QuickBlox Dashboard,
  otherwise you will get 405 error. To obtain HIPAA AI Gateway feature please contact us by [enterprise@quickblox.com](mail:enterprise@quickblox.com).
</Warning>

<Note>
  Accepted image types: jpeg, png.
  Max image size: 50MB.
</Note>

#### Recipes

<AccordionGroup>
  <Accordion title="Create chat completion">
    ```bash cURL theme={null}
    curl -X POST \
    -H "Content-Type: application/json" \
    -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
    -d '{
      "smart_chat_assistant_id": "65d5f3473d5d68095462165d",
      "messages": [
        {
          "role": "developer",
          "content": "You are helpful assistant"
        },
        {
          "role": "user",
          "content": "Hi"
        }
      ]
    }' \
    https://api.quickblox.com/ai/ai_extensions/ai_gateway
    ```
  </Accordion>

  <Accordion title="Analize image with URL">
    <Note>
      Accepted image types: jpeg, png.
      Max image size: 50MB.
    </Note>

    ```bash cURL theme={null}
    curl -X POST \
    -H "Content-Type: application/json" \
    -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
    -d '{
      "smart_chat_assistant_id": "65d5f3473d5d68095462165d",
      "messages": [
        {
          "role": "developer",
          "content": "You are helpful assistant"
        },
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "What's in this image?"
            },
            {
              "type": "image_url",
              "image_url": {
                  "url": "https://some_website/image.jpg"
              }
            }
          ]
        }
      ]
    }' \
    https://api.quickblox.com/ai/ai_extensions/ai_gateway
    ```
  </Accordion>

  <Accordion title="Analize image with Base64 encoded image">
    ```bash cURL theme={null}
    curl -X POST \
    -H "Content-Type: application/json" \
    -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
    -d '{
      "smart_chat_assistant_id": "65d5f3473d5d68095462165d",
      "messages": [
        {
          "role": "developer",
          "content": "You are helpful assistant"
        },
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "What's in this image?"
            },
            {
              "type": "image_url",
              "image_url": {
                  "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAYGBgYHBgcICAcKCwoLCg8ODAwODxYQERAREBYiFRkVFRkVIh4kHhweJB42KiYmKjY…"
              }
            }
          ]
        }
      ]
    }' \
    https://api.quickblox.com/ai/ai_extensions/ai_gateway
    ```
  </Accordion>
</AccordionGroup>

#### Body Parameters

<ParamField body="smart_chat_assistant_id" type="string" required>
  Smart Chat Assistant ID.
</ParamField>

<ParamField body="messages" type="array">
  Messages in OpenAI format. Please refer to OpenAI documentation [OpenAI messaging documentation](https://platform.openai.com/docs/guides/text?api-mode=chat#message-roles-and-instruction-following), [OpenAI analyze images documentation](https://platform.openai.com/docs/guides/images-vision?api-mode=chat#analyze-images).

  <Expandable title="Message">
    <ParamField body="role" type="string" required>
      May be user, assistant, or developer.
    </ParamField>

    <ParamField body="content" type="string or array" required>
      Text content `string`

      Array of content parts `array`

      <Expandable title="Text content part">
        <ParamField body="type" type="string" required>
          `text`
        </ParamField>

        <ParamField body="text" type="string" required>
          Text message
        </ParamField>
      </Expandable>

      <Expandable title="Image content part">
        <ParamField body="type" type="string" required>
          `image_url`
        </ParamField>

        <ParamField body="image_url" type="object" required>
          <Expandable title="Image url">
            <ParamField body="url" type="string" required>
              Image url or Base64 encoded image.
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required>
  A user or application session token. See [Authentication](/reference/authentication)
  page to learn more about session tokens.
</ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="200">
    A successful response

    <ResponseField name="answer" type="string" />
  </Accordion>

  <Accordion title="400">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>

  <Accordion title="404">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>

  <Accordion title="405">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
  -d '{
    "smart_chat_assistant_id": "65d5f3473d5d68095462165d",
    "messages": [
      {
        "role": "developer",
        "content": "You are helpful assistant"
      },
      {
        "role": "user",
        "content": "Hi"
      }
    ]
  }' \
  https://api.quickblox.com/ai/ai_extensions/ai_gateway
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "answer": "Hello! How can I assist you today?"
  }
  ```

  ```json 400 theme={null}
  {
    "errors": [
      "Failed to process AI Gateway request"
    ]
  }
  ```

  ```json 404 theme={null}
  {
    "errors": [
      "The resource wasn't found"
    ]
  }
  ```

  ```json 405 theme={null}
  {
    "errors": [
      "AI Gateway is disabled"
    ]
  }
  ```
</ResponseExample>
