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

# Embeddings

> Get embeddings from Bedrock

Bedrock supports embedding text and images through Amazon Titan and Cohere models.
Obiguard provides a standardized interface for embedding multiple modalities.

# Bedrock Titan

## Embedding Text

<Tabs>
  <Tab title="Python SDK">
    ```python Python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="sk-obg***", # Your Obiguard API key
      virtual_key="VIRTUAL_KEY",
    )

    embeddings = client.embeddings.create(
      model="amazon.titan-embed-text-v2:0",
      input="Hello this is a test",
      # normalize=False # if you would like to disable normalization
      # dimensions=1024, # embedding dimensions
      # encoding_format="float", # embedding format
    )
    ```
  </Tab>

  <Tab title="OpenAI SDK">
    ```python OpenAI Python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='NOT_REQUIRED',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="sk-obg******",  # Your Obiguard API key
      )
    )

    embeddings = client.embeddings.create(
      model="amazon.titan-embed-text-v2:0",
      input="Hello this is a test",
      # normalize=False # if you would like to disable normalization
      # dimensions=1024, # embedding dimensions
      # encoding_format="float", # embedding format
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```sh cURL theme={null}
    curl --location 'https://gateway.obiguard.ai/v1/embeddings' \
      --header 'Content-Type: application/json' \
      --header 'x-obiguard-api-key: $OBIGUARD_API_KEY' \
      --data-raw '{
        "model": "amazon.titan-embed-text-v2:0",
        "input": "Hello this is a test",
        "normalize": false, // if you would like to disable normalization
        "dimensions": 1024, // embedding dimensions
        "encoding_format": "float" // embedding format
      }'
    ```
  </Tab>
</Tabs>

## Embeddings Images

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="sk-obg***",  # Your Obiguard API key
      virtual_key="VIRTUAL_KEY",
    )

    embeddings = client.embeddings.create(
      model="amazon.titan-embed-image-v1",
      dimensions=256,
      input=[
        {
          "text": "this is the caption of the image",
          "image": {
            "base64": "UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
        }
      ]
    )
    ```
  </Tab>

  <Tab title="OpenAI SDK">
    ```python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='NOT_REQUIRED',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="sk-obg******",  # Your Obiguard API key
      )
    )

    embeddings = client.embeddings.create(
      model="amazon.titan-embed-image-v1",
      dimensions=256,
      input=[
        {
          "text": "this is the caption of the image",
          "image": {
            "base64": "UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
        }
      ]
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```sh cURL theme={null}
    curl --location 'https://gateway.obiguard.ai/v1/embeddings' \
      --header 'Content-Type: application/json' \
      --header 'x-obiguard-api-key: $OBIGUARD_API_KEY' \
      --data-raw '{
          "model": "amazon.titan-embed-image-v1",
          "dimensions": 256,
          "input": [
            {
              "text": "this is the caption of the image",
              "image": {
                "base64": "UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
              }
             }
           ]
        }'
    ```
  </Tab>
</Tabs>

# Cohere

## Embedding Text

<Tabs>
  <Tab title="Python SDK">
    ```python Python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="sk-obg***",  # Your Obiguard API key
      virtual_key="VIRTUAL_KEY",
    )

    embeddings = client.embeddings.create(
      model="cohere.embed-english-v3",
      input=["Hello this is a test", "skibidi"],
      input_type="classification"
    )
    ```
  </Tab>

  <Tab title="OpenAI SDK">
    ```python OpenAI Python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
    api_key='NOT_REQUIRED',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="sk-obg******",  # Your Obiguard API key
      )
    )

    embeddings = client.embeddings.create(
      model="cohere.embed-english-v3",
      input=["Hello this is a test", "skibidi"],
      input_type="classification"
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```sh cURL theme={null}
    curl --location 'https://gateway.obiguard.ai/v1/embeddings' \
      --header 'Content-Type: application/json' \
      --header 'x-obiguard-api-key: $OBIGUARD_API_KEY' \
      --data-raw '{
        "model": "cohere.embed-english-v3",
        "input": ["Hello this is a test", "skibidi"],
        "input_type": "classification"
      }'
    ```
  </Tab>
</Tabs>

## Embeddings Images

<Tabs>
  <Tab title="Python SDK">
    ```python Python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="sk-obg***", # Your Obiguard API key
      virtual_key="VIRTUAL_KEY",
    )

    embeddings = client.embeddings.create(
      model="cohere.embed-english-v3",
      input_type="image",
      dimensions=256,
      input=[
        {
          "image": {
            "base64": "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
        }
      ]
    )
    ```
  </Tab>

  <Tab title="OpenAI SDK">
    ```python OpenAI Python theme={null}
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key='NOT_REQUIRED',
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        provider="openai",
        obiguard_api_key="sk-obg******",  # Your Obiguard API key
      )
    )

    embeddings = client.embeddings.create(
      model="cohere.embed-english-v3",
      input_type="image",
      dimensions=256,
      input=[
        {
          image: {
            base64: "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
        }
      ]
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```sh cURL theme={null}
    curl --location 'https://gateway.obiguard.ai/v1/embeddings' \
      --header 'Content-Type: application/json' \
      --header 'x-obiguard-api-key: $OBIGUARD_API_KEY' \
      --data-raw '{
        "model": "cohere.embed-english-v3",
        "input_type": "image",
        "dimensions": 256,
        "input": [
          {
            "image": {
              "base64": "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
            }
          }
        ]
      }'
    ```
  </Tab>
</Tabs>
