> ## 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.
Portkey provides a standardized interface for embedding multiple modalities.

# Bedrock Titan

## Embedding Text

```python Python theme={"system"}
from portkey_ai import Portkey

client = Portkey(
    api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_API_KEY")
    provider="@PROVIDER",
)

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
)
```

```javascript NodeJS theme={"system"}
import { Portkey } from 'portkey-ai';

const portkey = new Portkey({
    apiKey: "YOUR_API_KEY",
    provider:"@YOUR_PROVIDER"
});

const embedding = await portkey.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
});

console.log(embedding);
```

```sh cURL theme={"system"}
curl --location 'https://api.portkey.ai/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: PORTKEY_API_KEY' \
--header 'x-portkey-provider: PORTKEY_PROVIDER' \
--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
}'
```

```python OpenAI Python theme={"system"}
from openai import OpenAI
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

portkey_client = OpenAI(
    api_key='NOT_REQUIRED',
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        provider="openai",
        api_key="PORTKEY_API_KEY"
    )
)

embeddings = portkey_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
)
```

```js OpenAI NodeJS theme={"system"}
import OpenAI from 'openai'; // We're using the v4 SDK
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'

const portkeyClient = new OpenAI({
  apiKey: 'NOT_REQUIRED', // defaults to process.env["OPENAI_API_KEY"],
  baseURL: PORTKEY_GATEWAY_URL,
  defaultHeaders: createHeaders({
    provider: "vertex-ai",
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
    provider:"@PORTKEY_PROVIDER"
  })
});

const embedding = await portkeyClient.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
});

console.log(embedding);
```

## Embeddings Images

```python Python theme={"system"}
from portkey_ai import Portkey

client = Portkey(
    api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_API_KEY")
    provider="@PROVIDER",
)

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

```javascript NodeJS theme={"system"}
import { Portkey } from 'portkey-ai';

const portkey = new Portkey({
    apiKey: "YOUR_API_KEY",
    provider:"@YOUR_PROVIDER"
});

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

console.log(embedding);
```

```sh cURL theme={"system"}
curl --location 'https://api.portkey.ai/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: PORTKEY_API_KEY' \
--header 'x-portkey-provider: PORTKEY_PROVIDER' \
--data-raw '{
"model": "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
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

portkey_client = OpenAI(
    api_key='NOT_REQUIRED',
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        provider="openai",
        api_key="PORTKEY_API_KEY"
    )
)

embeddings = portkey_client.embeddings.create(
    model="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
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'

const portkeyClient = new OpenAI({
  apiKey: 'NOT_REQUIRED', // defaults to process.env["OPENAI_API_KEY"],
  baseURL: PORTKEY_GATEWAY_URL,
  defaultHeaders: createHeaders({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
    provider:"@PORTKEY_PROVIDER"
  })
});

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

console.log(embedding);
```

# Cohere

## Embedding Text

```python Python theme={"system"}
from portkey_ai import Portkey

client = Portkey(
    api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_API_KEY")
    provider="@PROVIDER",
)

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

```javascript NodeJS theme={"system"}
import { Portkey } from 'portkey-ai';

const portkey = new Portkey({
    apiKey: "YOUR_API_KEY",
    provider:"@YOUR_PROVIDER"
});

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

console.log(embedding);
```

```sh cURL theme={"system"}
curl --location 'https://api.portkey.ai/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: PORTKEY_API_KEY' \
--header 'x-portkey-provider: PORTKEY_PROVIDER' \
--data-raw '{
  "model": "cohere.embed-english-v3",
  "input": ["Hello this is a test", "skibidi"],
  "input_type": "classification"
}'
```

```python OpenAI Python theme={"system"}
from openai import OpenAI
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

portkey_client = OpenAI(
    api_key='NOT_REQUIRED',
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        provider="openai",
        api_key="PORTKEY_API_KEY"
    )
)

embeddings = portkey_client.embeddings.create(
    model="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
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'

const portkeyClient = new OpenAI({
  apiKey: 'NOT_REQUIRED', // defaults to process.env["OPENAI_API_KEY"],
  baseURL: PORTKEY_GATEWAY_URL,
  defaultHeaders: createHeaders({
    provider: "vertex-ai",
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
    provider:"@PORTKEY_PROVIDER"
  })
});

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

console.log(embedding);
```

## Embeddings Images

```python Python theme={"system"}
from portkey_ai import Portkey

client = Portkey(
    api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_API_KEY")
    provider="@PROVIDER",
)

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

```javascript NodeJS theme={"system"}
import { Portkey } from 'portkey-ai';

const portkey = new Portkey({
    apiKey: "YOUR_API_KEY",
    provider:"@YOUR_PROVIDER"
});

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

console.log(embedding);
```

```sh cURL theme={"system"}
curl --location 'https://api.portkey.ai/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: PORTKEY_API_KEY' \
--header 'x-portkey-provider: PORTKEY_PROVIDER' \
--data-raw '{
"model": "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
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

portkey_client = OpenAI(
    api_key='NOT_REQUIRED',
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        provider="openai",
        api_key="PORTKEY_API_KEY"
    )
)

embeddings = portkey_client.embeddings.create(
    model="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
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'

const portkeyClient = new OpenAI({
  apiKey: 'NOT_REQUIRED', // defaults to process.env["OPENAI_API_KEY"],
  baseURL: PORTKEY_GATEWAY_URL,
  defaultHeaders: createHeaders({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
    provider:"@PORTKEY_PROVIDER"
  })
});

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

console.log(embedding);
```

***

> [card] [Portkey is now PRISMA AIRS AI Gateway. See it in action.](https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\&utm_medium=referral\&utm_campaign=prisma_airs\&utm_content=docs_nav#contact)
>
> Contact Us


## Related topics

- [Embeddings](https://docs.portkey.ai/docs/api-reference/inference-api/embeddings.md)
- [Guardrails for Embedding Requests](https://docs.portkey.ai/docs/product/guardrails/embedding-guardrails.md)
- [C# (.NET)](https://docs.portkey.ai/docs/api-reference/sdk/c-sharp.md)


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