Vertex AI SDK Integration
Integrate Proxy with the Google Vertex AI SDK to automatically capture telemetry. Demonstrated with Vertex AI’s Python SDK but should work in most languages.Base URL
Copy
Ask AI
https://gateway.adaline.ai/v1/vertex/
Chat Completions
Complete Chat
Copy
Ask AI
from google import genai
from google.genai import types
client = genai.Client(
http_options={
"base_url": "https://gateway.adaline.ai/v1/vertex",
"headers": {
"adaline-api-key": "your-adaline-api-key",
"adaline-project-id": "your-project-id",
"adaline-prompt-id": "your-prompt-id",
},
},
vertexai=True,
project="your-gcp-project-id",
location="us-central1",
)
response = client.models.generate_content(
model="gemini-1.5-pro",
contents="You are a helpful assistant.\n\nWhat are the advantages of using Google Cloud for AI workloads?",
config=types.GenerateContentConfig(
http_options=types.HttpOptions(
headers={
"adaline-trace-name": "vertex-chat-completion" # Optional
}
)
)
)
print(response.text)
Stream Chat
Copy
Ask AI
from google import genai
from google.genai import types
client = genai.Client(
http_options={
"base_url": "https://gateway.adaline.ai/v1/vertex",
"headers": {
"adaline-api-key": "your-adaline-api-key",
"adaline-project-id": "your-project-id",
"adaline-prompt-id": "your-prompt-id",
},
},
vertexai=True,
project="your-gcp-project-id",
location="us-central1",
)
stream = client.models.generate_content_stream(
model="gemini-1.5-pro",
contents="You are a helpful assistant.\n\nExplain the concept of serverless computing in detail.",
config=types.GenerateContentConfig(
http_options=types.HttpOptions(
headers={
"adaline-trace-name": "vertex-stream-chat" # Optional
}
)
)
)
for chunk in stream:
if hasattr(chunk, 'text') and chunk.text:
print(chunk.text, end="")
Embeddings
Copy
Ask AI
from google import genai
from google.genai import types
client = genai.Client(
http_options={
"base_url": "https://gateway.adaline.ai/v1/vertex",
"headers": {
"adaline-api-key": "your-adaline-api-key",
"adaline-project-id": "your-project-id",
"adaline-prompt-id": "your-prompt-id",
},
},
vertexai=True,
project="your-gcp-project-id",
location="us-central1",
)
response = client.models.embed_content(
model="text-embedding-004",
contents="The quick brown fox jumps over the lazy dog",
config=types.EmbedContentConfig(
http_options=types.HttpOptions(
headers={
"adaline-trace-name": "vertex-embedding" # Optional
}
)
)
)
Next Steps
- Multi-Step Workflows - Real-world examples from simple single-span workflows to complex multi-span applications
- Headers Reference - Complete header documentation