Bedrock Titan
Embedding Text
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
}'
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
)
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);
Embeddings Images
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....."
}
}
]
}'
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....."
}
}
]
)
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);
Cohere
Embedding Text
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"
}'
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"
)
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);
Embeddings Images
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....."
}
}
]
}'
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....."
}
}
]
)
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);

