OpenInference VertexAI Instrumentation
Project description
OpenInference Google VertexAI Instrumentation
Python auto-instrumentation library for VertexAI SDK and the Google Cloud AI Platform. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as Arize Phoenix.
Installation
pip install -Uqqq openinference-instrumentation-vertexai
Quickstart
Install openinference-instrumentation-vertexai and arize-phoenix.
pip install -U \
openinference-instrumentation-vertexai \
arize-phoenix \
opentelemetry-sdk \
opentelemetry-exporter-otlp \
"opentelemetry-proto>=1.12.0"
Start the phoenix server so that it is ready to receive traces.
The phoenix server runs entirely on your machine and does not send data over the internet.
python -m phoenix.server.main serve
Instrumenting vertexai is simple.
from openinference.instrumentation.vertexai import VertexAIInstrumentor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
endpoint = "http://127.0.0.1:4317"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
VertexAIInstrumentor().instrument(tracer_provider=tracer_provider)
Now, all calls by generative_models are instrumented and can be viewed in the phoenix UI.
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(location="us-central1")
model = GenerativeModel("gemini-1.5-flash")
print(model.generate_content("Why is sky blue?"))
More Info
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openinference_instrumentation_vertexai-0.1.8.tar.gz.
File metadata
- Download URL: openinference_instrumentation_vertexai-0.1.8.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
289da077bb72a1a2f97d1f8a260794025d6a75e1ce93b31dc8deef2683eb3663
|
|
| MD5 |
54654e5046dbfa7c112b8b6a44da3dce
|
|
| BLAKE2b-256 |
55b9ee35d327b454cac1f0b2b909830b8f8bd947e913973bfb3bffd2d4339a88
|
File details
Details for the file openinference_instrumentation_vertexai-0.1.8-py3-none-any.whl.
File metadata
- Download URL: openinference_instrumentation_vertexai-0.1.8-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4f78fe8cfe101f0bc4e7ac68fab68f2ec27112016675ac158d71703a8f50b67
|
|
| MD5 |
9bc6020fda5648a70d577004ad3b182c
|
|
| BLAKE2b-256 |
375a6a1647bc4cd2be2485d071db3d525efafe02c28cfa765d9e51b1b4bcb454
|