diff --git a/docs.json b/docs.json
index 9321fdd7..2d0d29fa 100644
--- a/docs.json
+++ b/docs.json
@@ -252,7 +252,8 @@
"integrations/llms/bedrock/files",
"integrations/llms/bedrock/batches",
"integrations/llms/bedrock/fine-tuning",
- "integrations/llms/bedrock/prompt-caching"
+ "integrations/llms/bedrock/prompt-caching",
+ "integrations/llms/bedrock/embeddings"
]
},
"integrations/llms/aws-sagemaker",
diff --git a/integrations/llms/bedrock/embeddings.mdx b/integrations/llms/bedrock/embeddings.mdx
new file mode 100644
index 00000000..e00f7cfe
--- /dev/null
+++ b/integrations/llms/bedrock/embeddings.mdx
@@ -0,0 +1,455 @@
+---
+title: "Embeddings"
+description: "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
+ from portkey_ai import Portkey
+
+ client = Portkey(
+ api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_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
+ )
+ ```
+
+ ```javascript NodeJS
+ import { Portkey } from 'portkey-ai';
+
+ const portkey = new Portkey({
+ apiKey: "YOUR_API_KEY",
+ virtualKey: "YOUR_VIRTUAL_KEY"
+ });
+
+ 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
+ curl --location 'https://api.portkey.ai/v1/embeddings' \
+ --header 'Content-Type: application/json' \
+ --header 'x-portkey-api-key: PORTKEY_API_KEY' \
+ --header 'x-portkey-virtual-key: PORTKEY_VIRTUAL_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
+ }'
+ ```
+
+ ```python OpenAI Python
+ 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
+ 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"]
+ virtualKey: "PORTKEY_VIRTUAL_KEY"
+ })
+ });
+
+ 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
+ from portkey_ai import Portkey
+
+ client = Portkey(
+ api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_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....."
+ }
+ }
+ ]
+ )
+ ```
+
+ ```javascript NodeJS
+ import { Portkey } from 'portkey-ai';
+
+ const portkey = new Portkey({
+ apiKey: "YOUR_API_KEY",
+ virtualKey: "YOUR_VIRTUAL_KEY"
+ });
+
+ 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
+ curl --location 'https://api.portkey.ai/v1/embeddings' \
+ --header 'Content-Type: application/json' \
+ --header 'x-portkey-api-key: PORTKEY_API_KEY' \
+ --header 'x-portkey-virtual-key: PORTKEY_VIRTUAL_KEY' \
+ --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
+ 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
+ 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"]
+ virtualKey: "PORTKEY_VIRTUAL_KEY"
+ })
+ });
+
+ 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
+ from portkey_ai import Portkey
+
+ client = Portkey(
+ api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_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"
+ )
+ ```
+
+ ```javascript NodeJS
+ import { Portkey } from 'portkey-ai';
+
+ const portkey = new Portkey({
+ apiKey: "YOUR_API_KEY",
+ virtualKey: "YOUR_VIRTUAL_KEY"
+ });
+
+ 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
+ curl --location 'https://api.portkey.ai/v1/embeddings' \
+ --header 'Content-Type: application/json' \
+ --header 'x-portkey-api-key: PORTKEY_API_KEY' \
+ --header 'x-portkey-virtual-key: PORTKEY_VIRTUAL_KEY' \
+ --data-raw '{
+ "model": "cohere.embed-english-v3",
+ "input": ["Hello this is a test", "skibidi"],
+ "input_type": "classification"
+ }'
+ ```
+
+ ```python OpenAI Python
+ 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
+ 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"]
+ virtualKey: "PORTKEY_VIRTUAL_KEY"
+ })
+ });
+
+ 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
+ from portkey_ai import Portkey
+
+ client = Portkey(
+ api_key="YOUR_PORTKEY_API_KEY", # defaults to os.environ.get("PORTKEY_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....."
+ }
+ }
+ ]
+ )
+ ```
+
+ ```javascript NodeJS
+ import { Portkey } from 'portkey-ai';
+
+ const portkey = new Portkey({
+ apiKey: "YOUR_API_KEY",
+ virtualKey: "YOUR_VIRTUAL_KEY"
+ });
+
+ 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
+ curl --location 'https://api.portkey.ai/v1/embeddings' \
+ --header 'Content-Type: application/json' \
+ --header 'x-portkey-api-key: PORTKEY_API_KEY' \
+ --header 'x-portkey-virtual-key: PORTKEY_VIRTUAL_KEY' \
+ --data-raw '{
+ "model": "cohere.embed-english-v3",
+ "input_type": "image",
+ "dimensions": 256,
+ "input": [
+ {
+ "image": {
+ "base64": "Data:image/webp;base64,UklGRkacAABXRUJQVlA4IDqcAACQggKdASqpAn8B....."
+ }
+ }
+ ]
+ }'
+ ```
+
+ ```python OpenAI Python
+ 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
+ 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"]
+ virtualKey: "PORTKEY_VIRTUAL_KEY"
+ })
+ });
+
+ 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);
+ ```
+
+
\ No newline at end of file