> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/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.
The Prisma AIRS AI Gateway provides a standardized interface for embedding multiple modalities.

# Bedrock Titan

## Embedding Text

<CodeGroup>
  ```sh cURL theme={"system"}
  curl --location 'https://aigw.portkey.ai/v1/embeddings' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer PORTKEY_API_KEY' \
  --data-raw '{
      "model": "@bedrock/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
  }'
  ```

  ```python OpenAI Python theme={"system"}
  from openai import OpenAI

  gateway_client = OpenAI(
      api_key="PORTKEY_API_KEY",
      base_url="https://aigw.portkey.ai/v1",
  )

  embeddings = gateway_client.embeddings.create(
      model="@bedrock/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
  )
  ```

  ```js OpenAI NodeJS theme={"system"}
  import OpenAI from 'openai'; // We're using the v4 SDK

  const gatewayClient = new OpenAI({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
    baseURL: "https://aigw.portkey.ai/v1"
  });

  const embedding = await gatewayClient.embeddings.create({
      model: "@bedrock/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
  });

  console.log(embedding);
  ```
</CodeGroup>

## Embeddings Images

<CodeGroup>
  ```sh cURL theme={"system"}
  curl --location 'https://aigw.portkey.ai/v1/embeddings' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer PORTKEY_API_KEY' \
  --data-raw '{
  "model": "@bedrock/amazon.titan-embed-image-v1",
  "dimensions": 256,
  "input": [
      {
          "text": "this is the caption of the image",
          "image": {
              "base64": "UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
      }
  ]
  }'
  ```

  ```python OpenAI Python theme={"system"}
  from openai import OpenAI

  gateway_client = OpenAI(
      api_key="PORTKEY_API_KEY",
      base_url="https://aigw.portkey.ai/v1",
  )

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

  ```js OpenAI NodeJS theme={"system"}
  import OpenAI from 'openai'; // We're using the v4 SDK

  const gatewayClient = new OpenAI({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
    baseURL: "https://aigw.portkey.ai/v1"
  });

  const embedding = await gatewayClient.embeddings.create({
      model: "@bedrock/amazon.titan-embed-image-v1",
      dimensions: 256,
      input: [
      {
          text: "this is the caption of the image",
          image: {
              base64: "UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
      }
      ]
  });

  console.log(embedding);
  ```
</CodeGroup>

# Cohere

## Embedding Text

<CodeGroup>
  ```sh cURL theme={"system"}
  curl --location 'https://aigw.portkey.ai/v1/embeddings' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer PORTKEY_API_KEY' \
  --data-raw '{
    "model": "@bedrock/cohere.embed-english-v3",
    "input": ["Hello this is a test", "skibidi"],
    "input_type": "classification"
  }'
  ```

  ```python OpenAI Python theme={"system"}
  from openai import OpenAI

  gateway_client = OpenAI(
      api_key="PORTKEY_API_KEY",
      base_url="https://aigw.portkey.ai/v1",
  )

  embeddings = gateway_client.embeddings.create(
      model="@bedrock/cohere.embed-english-v3",
      input=["Hello this is a test", "skibidi"],
      input_type="classification"
  )
  ```

  ```js OpenAI NodeJS theme={"system"}
  import OpenAI from 'openai'; // We're using the v4 SDK

  const gatewayClient = new OpenAI({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
    baseURL: "https://aigw.portkey.ai/v1"
  });

  const embedding = await gatewayClient.embeddings.create({
      model: "@bedrock/cohere.embed-english-v3",
      input: ["Hello this is a test", "skibidi"],
      input_type: "classification"
  });

  console.log(embedding);
  ```
</CodeGroup>

## Embeddings Images

<CodeGroup>
  ```sh cURL theme={"system"}
  curl --location 'https://aigw.portkey.ai/v1/embeddings' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer PORTKEY_API_KEY' \
  --data-raw '{
  "model": "@bedrock/cohere.embed-english-v3",
  "input_type": "image",
  "dimensions": 256,
  "input": [
      {
          "image": {
              "base64": "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
      }
  ]
  }'
  ```

  ```python OpenAI Python theme={"system"}
  from openai import OpenAI

  gateway_client = OpenAI(
      api_key="PORTKEY_API_KEY",
      base_url="https://aigw.portkey.ai/v1",
  )

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

  ```js OpenAI NodeJS theme={"system"}
  import OpenAI from 'openai'; // We're using the v4 SDK

  const gatewayClient = new OpenAI({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["OPENAI_API_KEY"],
    baseURL: "https://aigw.portkey.ai/v1"
  });

  const embedding = await gatewayClient.embeddings.create({
      model: "@bedrock/cohere.embed-english-v3",
      input_type: "image",
      dimensions: 256,
      input: [
      {
          image: {
              base64: "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
          }
      }
    ]
  });

  console.log(embedding);
  ```
</CodeGroup>


## Related topics

- [Embeddings](/docs/aigw/integrations/llms/openai/embeddings.md)
- [Create embedding](/docs/aigw/api-reference/embeddings/create-embedding.md)
- [Guardrails for Embedding Requests](/docs/aigw/product/guardrails/embedding-guardrails.md)
- [Langchain (JS/TS)](/docs/aigw/integrations/libraries/langchain-js.md)
