Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

add test vtx embedding

Ishaan Jafff947cec7fcdf
diff --git a/litellm/proxy/tests/test_vtx_embedding.py b/litellm/proxy/tests/test_vtx_embedding.py
new file mode 100644
index 00000000000..4c770ae2e9d
--- /dev/null
+++ b/litellm/proxy/tests/test_vtx_embedding.py
@@ -0,0 +1,21 @@
+import openai
+
+client = openai.OpenAI(api_key="sk-1234", base_url="http://0.0.0.0:4000")
+
+# # request sent to model set on litellm proxy, `litellm --model`
+response = client.embeddings.create(
+ model="multimodalembedding@001",
+ input=[],
+ extra_body={
+ "instances": [
+ {
+ "image": {
+ "gcsUri": "gs://cloud-samples-data/vertex-ai/llm/prompts/landmark1.png"
+ },
+ "text": "this is a unicorn",
+ },
+ ],
+ },
+)
+
+print(response)
diff --git a/litellm/proxy/tests/test_vtx_sdk_embedding.py b/litellm/proxy/tests/test_vtx_sdk_embedding.py
new file mode 100644
index 00000000000..a6468884f9a
--- /dev/null
+++ b/litellm/proxy/tests/test_vtx_sdk_embedding.py
@@ -0,0 +1,59 @@
+import vertexai
+from google.auth.credentials import Credentials
+from vertexai.vision_models import (
+ Image,
+ MultiModalEmbeddingModel,
+ Video,
+ VideoSegmentConfig,
+)
+
+LITELLM_PROXY_API_KEY = "sk-1234"
+LITELLM_PROXY_BASE = "http://0.0.0.0:4000/vertex-ai"
+
+import datetime
+
+
+class CredentialsWrapper(Credentials):
+ def __init__(self, token=None):
+ super().__init__()
+ self.token = token
+ self.expiry = None # or set to a future date if needed
+
+ def refresh(self, request):
+ pass
+
+ def apply(self, headers, token=None):
+ headers["Authorization"] = f"Bearer {self.token}"
+
+ @property
+ def expired(self):
+ return False # Always consider the token as non-expired
+
+ @property
+ def valid(self):
+ return True # Always consider the credentials as valid
+
+
+credentials = CredentialsWrapper(token=LITELLM_PROXY_API_KEY)
+
+vertexai.init(
+ project="adroit-crow-413218",
+ location="us-central1",
+ api_endpoint=LITELLM_PROXY_BASE,
+ credentials=credentials,
+ api_transport="rest",
+ request_metadata=[("Authorization", f"Bearer {LITELLM_PROXY_API_KEY}")],
+)
+
+model = MultiModalEmbeddingModel.from_pretrained("multimodalembedding")
+image = Image.load_from_file(
+ "gs://cloud-samples-data/vertex-ai/llm/prompts/landmark1.png"
+)
+
+embeddings = model.get_embeddings(
+ image=image,
+ contextual_text="Colosseum",
+ dimension=1408,
+)
+print(f"Image Embedding: {embeddings.image_embedding}")
+print(f"Text Embedding: {embeddings.text_embedding}")