Trace Vertex AI requests
Trace Gemini requests on Vertex AI in Future AGI using the Google Gen AI SDK.
Choose the SDK
For new applications, use traceAI-google-genai with google-genai. Its GoogleGenAIInstrumentor wraps the SDK's synchronous and asynchronous generation and streaming methods, including clients configured with vertexai=True.
traceAI-vertexai is the legacy integration for google-cloud-aiplatform. Google deprecated its generative AI modules, including vertexai.generative_models, and announced their removal after June 24, 2026. This package supports google-cloud-aiplatform>=1.61.0,<=1.101.0; the lower bound allows the protobuf version required by the tracing dependencies, and the upper bound retains a release containing those modules. It does not instrument google-genai. Do not install the separate vertexai distribution to set up either route.
Set up Google Gen AI (recommended)
Install the maintained instrumentation package and SDK:
pip install traceAI-google-genai google-genai
You need a Google Cloud project with Vertex AI enabled, access to your chosen model in the selected location, and Application Default Credentials. For local development:
gcloud auth application-default login
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="global"
export GOOGLE_GENAI_MODEL="your-enabled-model-id"
export FI_API_KEY="your-future-agi-api-key"
export FI_SECRET_KEY="your-future-agi-secret-key"
Use a model ID available to your project and location. In a deployed application, use its service account or another supported Application Default Credentials configuration instead of an interactive login.
Register the tracer and instrument the SDK before making requests:
import os
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from google import genai
from traceai_google_genai import GoogleGenAIInstrumentor
def main():
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="vertexai_app",
)
GoogleGenAIInstrumentor().instrument(tracer_provider=trace_provider)
try:
client = genai.Client(
vertexai=True,
project=os.environ["GOOGLE_CLOUD_PROJECT"],
location=os.environ.get("GOOGLE_CLOUD_LOCATION", "global"),
)
response = client.models.generate_content(
model=os.environ["GOOGLE_GENAI_MODEL"],
contents="Write a haiku about a mountain trail.",
)
print(response.text)
finally:
trace_provider.force_flush()
if __name__ == "__main__":
main()
This example is also available as examples/google_genai_vertex.py. Open the vertexai_app project in Future AGI Observe to inspect the generation span, input, output and token usage returned by the SDK.
Keep an existing legacy application running
For applications that still import vertexai.generative_models, install the bounded legacy dependency rather than upgrading it past the supported range:
pip install traceAI-vertexai 'google-cloud-aiplatform==1.101.0'
Use the same Google Cloud and Future AGI credentials above, but select a region where your model is available. Older supported legacy SDKs reject global; if you set it for the recommended route, override it before running the legacy example:
export GOOGLE_CLOUD_LOCATION="us-central1"
The legacy example defaults to us-central1 when the variable is unset. Instrument before importing vertexai so the legacy SDK's GAPIC clients are wrapped when they are created:
import os
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_vertexai import VertexAIInstrumentor
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="vertexai_legacy_app",
)
VertexAIInstrumentor().instrument(tracer_provider=trace_provider)
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(
project=os.environ["GOOGLE_CLOUD_PROJECT"],
location=os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1"),
)
try:
response = GenerativeModel(os.environ["GOOGLE_GENAI_MODEL"]).generate_content(
"Write a haiku about a mountain trail."
)
print(response.text)
finally:
trace_provider.force_flush()
The pin preserves the SDK modules, not retired models or service endpoints. Migrate the application's imports, client construction and calls using Google's migration guide, then replace VertexAIInstrumentor with GoogleGenAIInstrumentor. Do not enable both instrumentors for the same SDK call.
Troubleshooting
ModuleNotFoundError: vertexai.generative_models: migrate to the recommended Google Gen AI route, or install the legacy version shown above. Installingvertexaiseparately is not the migration.- No generation spans after switching to
google-genai: replaceVertexAIInstrumentorwithGoogleGenAIInstrumentor; they target different SDKs. - Authentication, model-not-found or location errors: check Application Default Credentials, Vertex AI permissions, and the model's availability in your project and location. Changing the tracing package does not restore retired models.
Metadata
Release files for traceAI-vertexai 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_vertexai-0.1.11.tar.gz | 14.1 kB | With provenance | Details for traceai_vertexai-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_vertexai-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for traceai_vertexai-0.1.11-py3-none-any.whl |
Total release size: 29.0 kB
Release files / traceai_vertexai-0.1.11.tar.gz
| Download URL | traceai_vertexai-0.1.11.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a726104ad92f700900f536bd61c5a6e4e6f95534cc4c2d5b1505f04cc066bc3
|
|
BLAKE2b-256 checksum How to use checksums |
b2e97cea23c0cc5d9984e96e16ad3105893307773d985ef826f3ca8e2dbf6f11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / traceai_vertexai-0.1.11-py3-none-any.whl
| Download URL | traceai_vertexai-0.1.11-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c2fedf00e11bcf0631b7812828165b23c66c908e728156368ea4dc6c30837d6
|
|
BLAKE2b-256 checksum How to use checksums |
bb55314f582cbd093c5c30544e0822212f3cd8c03a96aabc1b0041179f7633db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for traceAI-vertexai 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for traceai_vertexai-0.1.11.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.