# openinference-instrumentation-vertexai

**Python · Instrumentation**

OpenInference VertexAI Instrumentation

- **Module**: `openinference.instrumentation.vertexai`
- **Version**: 0.1.38
- **Python**: >=3.10, <3.16
- **Instruments**: `google-cloud-aiplatform >= 1.63.0`

[PyPI](https://pypi.org/project/openinference-instrumentation-vertexai/) · [README](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-vertexai/README.md) · [Source](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-vertexai)

## Install

```sh
pip install openinference-instrumentation-vertexai
```

## Usage

Instrument once, at startup, before the library is used. The [`VertexAIInstrumentor`](https://openinf.dev/python/openinference-instrumentation-vertexai.html.md#openinference.instrumentation.vertexai.VertexAIInstrumentor) reference below lists the options.

```python
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation import TraceConfig
from openinference.instrumentation.vertexai import VertexAIInstrumentor

tracer_provider = TracerProvider()
# ...add a span processor that exports to Phoenix or any OTLP backend.

VertexAIInstrumentor().instrument(
    tracer_provider=tracer_provider,
    config=TraceConfig(hide_inputs=True),  # optional
)
```

## `openinference.instrumentation.vertexai`

### `VertexAIInstrumentor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-vertexai/src/openinference/instrumentation/vertexai/__init__.py#L17-L56)

```python
class VertexAIInstrumentor(BaseInstrumentor)
```

An instrumentor for `google-cloud-aiplatform` or the `vertexai` SDK

#### `instrument`

_method_

```python
def instrument(
    *,
    tracer_provider: Optional[TracerProvider] = None,
    config: Optional[TraceConfig] = None,
    skip_dep_check: bool = False,
) -> None
```

Start tracing `google-cloud-aiplatform`: patch it so its calls make OpenInference spans. Calling it again does nothing. Inherited from OpenTelemetry’s [`BaseInstrumentor`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/base/instrumentor.html).

**Parameters**

| Name | Description |
| - | - |
| `tracer_provider` | The tracer provider the spans are made with. Defaults to the global one, `opentelemetry.trace.get_tracer_provider()`. |
| `config` | What the spans record: hide inputs, outputs or messages, or limit image sizes. Defaults to `TraceConfig()`, which reads the `OPENINFERENCE_*` environment variables. See [`TraceConfig`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig). |
| `skip_dep_check` | Instrument even if the installed version of `google-cloud-aiplatform` is outside the supported range. |

#### `uninstrument`

_method_

```python
def uninstrument() -> None
```

Stop tracing: undo the patches `instrument()` made. Inherited from OpenTelemetry’s [`BaseInstrumentor`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/base/instrumentor.html).

#### `instrumentation_dependencies`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-vertexai/src/openinference/instrumentation/vertexai/__init__.py#L24-L25)

```python
def instrumentation_dependencies() -> Collection[str]
```
