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

