# openinference-instrumentation

**Python · Core**

OpenInference instrumentation utilities

- **Module**: `openinference.instrumentation`
- **Version**: 0.1.80
- **Python**: >=3.10, <3.16

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

## Install

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

## `openinference.instrumentation`

### `capture_span_context`

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

```python
class capture_span_context()
```

Context manager for capturing OpenInference span context.

**Examples**

```python
with capture_span_context() as capture:
    response = openai_client.chat.completions.create(...)
    phoenix_client.annotations.add_span_annotation(
        span_id=capture.get_last_span_id(),
        annotation_name="feedback",
        ...
    )
```

#### `get_first_span_id`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_capture.py#L55-L60)

```python
def get_first_span_id() -> Optional[str]
```

Returns the first captured span ID, or None if no spans were captured. This can be useful if the first span is the one that you want to annotate or evaluate.

#### `get_last_span_id`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_capture.py#L62-L67)

```python
def get_last_span_id() -> Optional[str]
```

Returns the last captured span ID, or None if no spans were captured. This can be useful if the last span is the one that you want to annotate or evaluate.

#### `get_span_contexts`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_capture.py#L69-L73)

```python
def get_span_contexts() -> Sequence[SpanContext]
```

Returns a sequence of all captured span contexts.

### `get_attributes_from_context`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L463-L470)

```python
def get_attributes_from_context() -> Iterator[Tuple[str, AttributeValue]]
```

Also importable from `openinference.instrumentation.context_attributes`.

Yield the OpenInference context attributes currently attached to the OpenTelemetry context. `OITracer` calls this when a span starts to copy them onto the span.

### `using_attributes`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L375-L460)

```python
class using_attributes(
    *,
    session_id: str = '',
    user_id: str = '',
    metadata: Optional[Dict[str, Any]] = None,
    tags: Optional[List[str]] = None,
    prompt_template: str = '',
    prompt_template_version: str = '',
    prompt_template_variables: Optional[Dict[str, Any]] = None,
)
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add attributes to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the attributes to the traced span, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

It is a convenient context manager to use if you find yourself using many others, provided by this package, combined.

**Example**

```python
tags = [
    "tag_1",
    "tag_2",
    ...
]
metadata = {
    "key-1": value_1,
    "key-2": value_2,
    ...
}
prompt_template = "Please describe the weather forecast for {city} on {date}"
prompt_template_variables = {"city": "Johannesburg", date:"July 11"}
prompt_template_version = "v1.0"
with using_attributes(
    session_id="my-session-id",
    user_id="my-user-id",
    metadata=metadata,
    tags=tags,
    prompt_template=prompt_template,
    prompt_template_version=prompt_template_version,
    prompt_template_variables=prompt_template_variables,
):
    # Tracing within this block will include the span attribute:
    # "session.id" = "my-session-id"
    # "user.id" = "my-user-id"
    # "metadata" = "{"key-1": value_1, "key-2": value_2, ... }"
    # "tag.tags" = "["tag_1","tag_2",...]"
    # "llm.prompt_template.template" = "Please describe the weather forecast
    for {city} on {date}"
    # "llm.prompt_template.variables" = "{"city": "Johannesburg",
    "date": "July 11"}"
    # "llm.prompt_template.version " = "v1.0"



    ...
```

**The previous example is equivalent to doing**

```python
with (
    using_session("my-session-id"),
    using_user("my-user-id"),
    using_metadata(metadata),
    using_tags(tags),
    using_prompt_template(
        template=prompt_template,
        version=prompt_template_version,
        variables=prompt_template_variables,
    ),
):
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `using_metadata`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L284-L306)

```python
class using_metadata(metadata: Dict[str, Any])
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add metadata to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the metadata as a span attribute, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

**Examples**

```python
metadata = {
    "key-1": value_1,
    "key-2": value_2,
    ...
}
with using_metadata(metadata):
    # Tracing within this block will include the span attribute:
    # "metadata" = "{"key-1": value_1, "key-2": value_2, ... }"
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `using_prompt_template`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L334-L372)

```python
class using_prompt_template(
    *,
    template: str = '',
    version: str = '',
    variables: Optional[Dict[str, Any]] = None,
)
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add prompt template, with its version and variables a to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the prompt template as a span attribute, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

**Examples**

```python
prompt_template = "Please describe the weather forecast for {city} on {date}"
prompt_template_variables = {"city": "Johannesburg", date:"July 11"}
with using_prompt_template(
    template=prompt_template,
    version="v1.0",
    variables=prompt_template_variables,
):
    # Tracing within this block will include the span attribute:
    # "llm.prompt_template.template" = "Please describe the weather
    forecast for {city} on {date}"
    # "llm.prompt_template.version" = "v1.0"
    # "llm.prompt_template.variables" = "{"city": "Johannesburg",
    "date": "July 11"}"
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `using_session`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L244-L261)

```python
class using_session(session_id: str)
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add session id to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the session id as a span attribute, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

**Examples**

```python
with using_session("my-session-id"):
    # Tracing within this block will include the span attribute:
    # "session.id" = "my-session-id"
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `using_tags`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L309-L331)

```python
class using_tags(tags: List[str])
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add tags to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the tags as a span attribute, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

**Examples**

```python
tags = [
    "tag_1",
    "tag_2",
    ...
]
with using_tags(tags):
    # Tracing within this block will include the span attribute:
    # "tag.tags" = "["tag_1","tag_2",...]"
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `using_user`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L264-L281)

```python
class using_user(user_id: str)
```

Also importable from `openinference.instrumentation.context_attributes`.

Context manager to add user id to the current OpenTelemetry Context. OpenInference instrumentations will read this Context and pass the user id as a span attribute, following the OpenInference semantic conventions.

Also usable as a decorator on plain, `async def`, generator and async generator functions; the attributes then apply for the whole call.

**Examples**

```python
with using_user("my-user-id"):
    # Tracing within this block will include the span attribute:
    # "user.id" = "my-user-id"
    ...
```

#### `attach_context`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L155-L156)

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

#### `__call__`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py#L182-L241)

```python
def __call__(decorated_function: DecoratedCallable) -> DecoratedCallable
```

### `dangerously_using_project`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_projects.py#L31-L68)

```python
class dangerously_using_project(project_name: str)
```

A context manager that switches the project for all spans created within the context.

This is intended for use in notebook environments where it’s useful to be able to change the project associated with spans on the fly.

Note: This should not be used in production environments or complex OpenTelemetry setups. As dynamically modifying span resources in this way can lead to unexpected behavior.

**Parameters**

| Name | Type | Description |
| - | - | - |
| `project_name` | `str` | The project name to associate with spans created within the context. |

Examples:

`python with dangerously_using_project('my_project'): # Spans created here will be associated with 'my_project'`

**Attributes**

| Name | Type and value |
| - | - |
| [`project_name`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.dangerously_using_project.project_name) | `project_name` |

### `safe_json_dumps`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/helpers.py#L15-L21)

```python
def safe_json_dumps(obj: Any, **kwargs: Any = {}) -> str
```

Also importable from `openinference.instrumentation.helpers`.

A convenience wrapper around `json.dumps` that ensures that any object can be safely encoded without a `TypeError` and that non-ASCII Unicode characters are not escaped.

### `suppress_tracing`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L43-L79)

```python
class suppress_tracing
```

Also importable from `openinference.instrumentation.config`.

Context manager to pause OpenTelemetry instrumentation.

**Examples**

```python
with suppress_tracing():
    # No tracing will occur within this block
    ...

async with suppress_tracing():
    # No tracing will occur within this block
    ...
```

### `TraceConfig`

_dataclass_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L145-L538)

```python
class TraceConfig(
    hide_llm_invocation_parameters: Optional[bool] = None,
    hide_llm_tools: Optional[bool] = None,
    hide_inputs: Optional[bool] = None,
    hide_outputs: Optional[bool] = None,
    hide_input_messages: Optional[bool] = None,
    hide_output_messages: Optional[bool] = None,
    hide_input_images: Optional[bool] = None,
    hide_input_text: Optional[bool] = None,
    hide_output_text: Optional[bool] = None,
    hide_embedding_vectors: Optional[bool] = None,
    hide_embeddings_vectors: Optional[bool] = None,
    hide_embeddings_text: Optional[bool] = None,
    hide_prompts: Optional[bool] = None,
    hide_choices: Optional[bool] = None,
    hide_retrieval_documents: Optional[bool] = None,
    enable_genai_semconv: Optional[bool] = None,
    base64_image_max_length: Optional[int] = None,
    blob_uploader: Optional[BlobUploader] = None,
)
```

Also importable from `openinference.instrumentation.config`.

TraceConfig helps you modify the observability level of your tracing. For instance, you may want to keep sensitive information from being logged for security reasons, or you may want to limit the size of the base64 encoded images to reduce payloads.

For those attributes not passed, this object tries to read from designated environment variables and, if not found, has default values that maximize observability.

**Attributes**

| Name | Type and value |
| - | - |
| [`hide_llm_invocation_parameters`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_llm_invocation_parameters) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_LLM_INVOCATION_PARAMETERS, 'default_value': DEFAULT_HIDE_...` |
| [`hide_llm_tools`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_llm_tools) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_LLM_TOOLS, 'default_value': DEFAULT_HIDE_LLM_TOOLS})`Hides the tool definitions advertised to the LLM |
| [`hide_inputs`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_inputs) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_INPUTS, 'default_value': DEFAULT_HIDE_INPUTS})`Hides input value, input images, input documents & messages |
| [`hide_outputs`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_outputs) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_OUTPUTS, 'default_value': DEFAULT_HIDE_OUTPUTS})`Hides output value, output images, output documents & messages |
| [`hide_input_messages`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_input_messages) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_INPUT_MESSAGES, 'default_value': DEFAULT_HIDE_INPUT_MESSA...`Hides all input messages |
| [`hide_output_messages`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_output_messages) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_OUTPUT_MESSAGES, 'default_value': DEFAULT_HIDE_OUTPUT_MES...`Hides all output messages |
| [`hide_input_images`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_input_images) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_INPUT_IMAGES, 'default_value': DEFAULT_HIDE_INPUT_IMAGES})`Hides images from input messages and the span-level input.images |
| [`hide_input_text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_input_text) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_INPUT_TEXT, 'default_value': DEFAULT_HIDE_INPUT_TEXT})`Hides text from input messages, including message document content |
| [`hide_output_text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_output_text) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_OUTPUT_TEXT, 'default_value': DEFAULT_HIDE_OUTPUT_TEXT})`Hides text from output messages, including message document content |
| [`hide_embedding_vectors`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_embedding_vectors) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_EMBEDDING_VECTORS, 'default_value': DEFAULT_HIDE_EMBEDDIN...`Deprecated: use hide_embeddings_vectors instead |
| [`hide_embeddings_vectors`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_embeddings_vectors) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_EMBEDDINGS_VECTORS, 'default_value': DEFAULT_HIDE_EMBEDDI...`Hides embedding vectors |
| [`hide_embeddings_text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_embeddings_text) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_EMBEDDINGS_TEXT, 'default_value': DEFAULT_HIDE_EMBEDDINGS...`Hides embedding text |
| [`hide_prompts`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_prompts) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_PROMPTS, 'default_value': DEFAULT_HIDE_PROMPTS})`Hides LLM prompts (completions API) |
| [`hide_choices`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_choices) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_CHOICES, 'default_value': DEFAULT_HIDE_CHOICES})`Hides LLM choices (completions API outputs) |
| [`hide_retrieval_documents`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.hide_retrieval_documents) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_HIDE_RETRIEVAL_DOCUMENTS, 'default_value': DEFAULT_HIDE_RETRIE...`Redacts the content and metadata of documents on RETRIEVER spans (`retrieval.documents.*.document.content` / `retrieval.documents.*.document.metadata`). `hide_outputs` implies this, mirroring how it already redacts `reranker.output_documents.*`. |
| [`enable_genai_semconv`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.enable_genai_semconv) | `Optional[bool] = field(default=None, metadata={'env_var': OPENINFERENCE_ENABLE_GENAI_SEMCONV, 'default_value': DEFAULT_ENABLE_GENAI_SE...`Emits OTel GenAI semantic conventions alongside OpenInference attributes |
| [`base64_image_max_length`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.base64_image_max_length) | `Optional[int] = field(default=None, metadata={'env_var': OPENINFERENCE_BASE64_IMAGE_MAX_LENGTH, 'default_value': DEFAULT_BASE64_IMAGE...`Limits characters of a base64 data URI in an image or document url |
| [`blob_uploader`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig.blob_uploader) | `Optional[BlobUploader] = field(default=None, metadata={'env_var': None, 'default_value': None})`Uploads base64 images and documents exceeding base64_image_max_length to external storage and records the destination URI in the span attribute instead of redacting. OpenInference ships no implementation — pass any object satisfying the BlobUploader protocol, or set the OPENINFERENCE_BLOB_UPLOADER environment variable to the name of an uploader registered under the “openinference_blob_uploader” entry-point group. |

#### `mask`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L355-L464)

```python
def mask(
    key: str,
    value: Union[AttributeValue, Callable[[], AttributeValue]],
    *,
    externalize: bool = True,
) -> Optional[AttributeValue]
```

### `OITracer`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L96-L795)

```python
class OITracer(wrapped: Tracer, config: TraceConfig)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`id_generator`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.OITracer.id_generator) | `IdGenerator` |

#### `start_as_current_span`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L109-L141)

```python
def start_as_current_span(
    name: str,
    context: Optional[Context] = None,
    kind: SpanKind = SpanKind.INTERNAL,
    attributes: Attributes = None,
    links: Optional[Sequence[Link]] = (),
    start_time: Optional[int] = None,
    record_exception: bool = True,
    set_status_on_exception: bool = True,
    end_on_exit: bool = True,
    *,
    openinference_span_kind: Optional[OpenInferenceSpanKind] = None,
) -> Iterator[OpenInferenceSpan]
```

#### `start_span`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L143-L202)

```python
def start_span(
    name: str,
    context: Optional[Context] = None,
    kind: SpanKind = SpanKind.INTERNAL,
    attributes: Attributes = None,
    links: Optional[Sequence[Link]] = (),
    start_time: Optional[int] = None,
    record_exception: bool = True,
    set_status_on_exception: bool = True,
    *,
    openinference_span_kind: Optional[OpenInferenceSpanKind] = None,
) -> OpenInferenceSpan
```

#### `agent`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L245-L259)

```python
def agent(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `chain`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L279-L289)

```python
def chain(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `retriever`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L309-L319)

```python
def retriever(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `reranker`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L339-L349)

```python
def reranker(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `guardrail`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L369-L379)

```python
def guardrail(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `evaluator`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L399-L409)

```python
def evaluator(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `tool`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L492-L552)

```python
def tool(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
    description: Optional[str] = None,
    parameters: Optional[Union[str, Dict[str, Any]]] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `llm`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L579-L597)

```python
def llm(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
    process_input: Optional[Callable[ParametersType, Mapping[str, AttributeValue]]] = None,
    process_output: Optional[Callable[..., Mapping[str, AttributeValue]]] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

#### `decision`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracers.py#L624-L652)

```python
def decision(
    wrapped_function: Optional[Callable[ParametersType, ReturnType]] = None,
    /,
    *,
    name: Optional[str] = None,
    process_input: Optional[Callable[ParametersType, Mapping[str, AttributeValue]]] = None,
    process_output: Optional[Callable[..., Mapping[str, AttributeValue]]] = None,
) -> Union[Callable[ParametersType, ReturnType], Callable[[Callable[ParametersType, ReturnType]], Callable[ParametersType, ReturnType]]]
```

Trace a decision model call as a DECISION span.

A decision model scores or selects among candidate options supplied in the request rather than generating text. The decorator behaves exactly like [`llm`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.OITracer.llm): it captures the arguments as `input.value` and the return value as `output.value` unless `process_input` / `process_output` are given, and supports sync, async, generator and async generator functions. Use [`get_decision_attributes`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.get_decision_attributes) in those callbacks to record the `decision.*` model identification and token counts.

### `REDACTED_VALUE`

_attribute_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L120)

```python
REDACTED_VALUE = '__REDACTED__'
```

Also importable from `openinference.instrumentation.config`.

### `Blob`

_dataclass_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L75-L96)

```python
class Blob(
    data: bytes,
    mime_type: str,
    modality: str = '',
    attribute_key: Optional[str] = None,
    content_sha256: str = '',
)
```

A unit of binary content captured during instrumentation, e.g. the decoded payload of a base64 data URI found in a span attribute.

**Attributes**

| Name | Type and value |
| - | - |
| [`data`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Blob.data) | `bytes` |
| [`mime_type`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Blob.mime_type) | `str` |
| [`modality`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Blob.modality) | `str = ''`One of “image”, “audio”, “video”, or “document”. Derived from the mime type when not provided. |
| [`attribute_key`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Blob.attribute_key) | `Optional[str] = None`The span attribute key the content was captured from, if any. |
| [`content_sha256`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Blob.content_sha256) | `str = field(default='')`Hex digest of the decoded bytes. Computed automatically. |

### `BlobUploader`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L99-L117)

```python
class BlobUploader(Protocol)
```

Uploads blobs to external storage, returning a reference URI that is recorded in span attributes in place of inline base64 content.

#### `upload`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L106-L113)

```python
def upload(blob: Blob) -> Optional[str]
```

Returns the destination URI immediately and performs the actual write asynchronously, or returns None if the blob cannot be accepted (the caller then falls back to redaction). Must not block the instrumented call path.

#### `shutdown`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L115-L117)

```python
def shutdown(timeout_sec: float = 10.0) -> None
```

Flushes pending uploads and stops background workers.

### `decode_base64_data_uri_to_blob`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L199-L214)

```python
def decode_base64_data_uri_to_blob(
    url: str,
    attribute_key: Optional[str] = None,
) -> Optional[Blob]
```

Decodes a base64 data URI into a `Blob`, or returns None if the value is not a base64 data URI or the payload cannot be decoded.

### `load_blob_uploader`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L123-L148)

```python
def load_blob_uploader(name: str) -> Optional[BlobUploader]
```

Loads a `BlobUploader` registered under the `openinference_blob_uploader` entry-point group (mirroring OTel util-genai’s `opentelemetry_genai_completion_hook` mechanics). The entry point may resolve to an uploader instance or to a zero-argument callable (e.g. a class) producing one. Returns None — and logs — when the name is unknown or the loaded object does not satisfy the protocol.

Loads are memoized per name: every `TraceConfig` constructed in the process shares one uploader instance (one worker pool, one queue), rather than each instrumentor spawning its own.

A package providing an uploader registers it in its packaging metadata:

`python [project.entry-points.openinference_blob_uploader] arize = "arize_otel.blob:ArizeBlobUploader"`

and users select it with `OPENINFERENCE_BLOB_UPLOADER=arize` — no application code required.

### `parse_base64_data_uri`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_blob_upload.py#L55-L65)

```python
def parse_base64_data_uri(url: str) -> Optional[Tuple[str, str]]
```

Parses a `data:<mime>;base64,<payload>` URI of any media type. Returns `(mime_type, base64_payload)`, or None if the value is not a base64 data URI.

### `TracerProvider`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracer_providers.py#L15-L33)

```python
class TracerProvider(
    *args: Any = (),
    config: Optional[TraceConfig] = None,
    **kwargs: Any = {},
)
```

#### `get_tracer`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_tracer_providers.py#L27-L33)

```python
def get_tracer(*args: Any = (), **kwargs: Any = {}) -> OITracer
```

### `get_context_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L407-L423)

```python
def get_context_attributes(
    *,
    session_id: Optional[str] = None,
    user_id: Optional[str] = None,
    metadata: Optional[Union[str, Dict[str, Any]]] = None,
    tags: Optional[List[str]] = None,
) -> Dict[str, AttributeValue]
```

### `get_annotation_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L246-L260)

```python
def get_annotation_attributes(
    *,
    annotations: Sequence[Annotation],
    scope: AnnotationScope = 'span',
) -> Dict[str, AttributeValue]
```

Return flattened OpenInference attributes for annotations.

Collection indices are assigned in input order. Metadata dictionaries are JSON-serialized, while metadata strings are preserved as provided.

### `get_decision_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L845-L878)

```python
def get_decision_attributes(
    *,
    provider: Optional[OpenInferenceDecisionProvider] = None,
    system: Optional[OpenInferenceDecisionSystem] = None,
    model_name: Optional[str] = None,
    request_model_name: Optional[str] = None,
    response_model_name: Optional[str] = None,
    token_count: Optional[DecisionTokenCount] = None,
) -> Dict[str, AttributeValue]
```

Build OpenInference DECISION span attributes.

A decision model scores or selects among candidate options supplied in the request rather than generating text, so decision spans identify the model under `decision.*` instead of `llm.*`. The arguments mirror [`get_llm_attributes`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.get_llm_attributes) and follow the same rules: `system` names the decision API ecosystem the call conforms to, `provider` names who hosts the model, and `decision.model_name` is `model_name`, else `response_model_name`, else `request_model_name`. `decision.request.model_name` and `decision.response.model_name` are set only when those arguments are passed.

Decision spans have no input or output messages; record the raw request and response with `span.set_input` / `span.set_output`.

### `get_decision_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L903-L906)

```python
def get_decision_model_name_attributes(
    model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_decision_provider_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L881-L890)

```python
def get_decision_provider_attributes(
    provider: Optional[OpenInferenceDecisionProvider],
) -> Mapping[str, AttributeValue]
```

### `get_decision_request_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L909-L912)

```python
def get_decision_request_model_name_attributes(
    request_model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_decision_response_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L915-L918)

```python
def get_decision_response_model_name_attributes(
    response_model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_decision_system_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L893-L900)

```python
def get_decision_system_attributes(
    system: Optional[OpenInferenceDecisionSystem],
) -> Mapping[str, AttributeValue]
```

### `get_decision_token_count_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L921-L930)

```python
def get_decision_token_count_attributes(
    token_count: Optional[DecisionTokenCount],
) -> Mapping[str, AttributeValue]
```

### `get_embedding_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L388-L404)

```python
def get_embedding_attributes(
    *,
    model_name: Optional[str] = None,
    embeddings: Optional[List[Embedding]] = None,
) -> Dict[str, AttributeValue]
```

### `get_evaluation_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L263-L277)

```python
def get_evaluation_attributes(
    *,
    evaluations: Sequence[Annotation],
    scope: AnnotationScope = 'span',
) -> Dict[str, AttributeValue]
```

Return annotations encoded using evaluation terminology.

Collection indices are assigned in input order. Metadata dictionaries are JSON-serialized, while metadata strings are preserved as provided.

### `get_input_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L454-L474)

```python
def get_input_attributes(
    value: Any,
    *,
    mime_type: Optional[OpenInferenceMimeType] = None,
) -> Dict[str, AttributeValue]
```

### `get_llm_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L594-L624)

```python
def get_llm_attributes(
    *,
    provider: Optional[OpenInferenceLLMProvider] = None,
    system: Optional[OpenInferenceLLMSystem] = None,
    model_name: Optional[str] = None,
    request_model_name: Optional[str] = None,
    response_model_name: Optional[str] = None,
    invocation_parameters: Optional[Union[str, Dict[str, Any]]] = None,
    input_messages: Optional[Sequence[Message]] = None,
    output_messages: Optional[Sequence[Message]] = None,
    token_count: Optional[TokenCount] = None,
    tools: Optional[Sequence[Tool]] = None,
) -> Dict[str, AttributeValue]
```

Build OpenInference LLM span attributes.

`llm.model_name` is `model_name`, else `response_model_name`, else `request_model_name`. `llm.request.model_name` and `llm.response.model_name` are set only when those arguments are passed.

### `get_llm_input_message_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L693-L698)

```python
def get_llm_input_message_attributes(
    messages: Optional[Sequence[Message]],
) -> Mapping[str, AttributeValue]
```

### `get_llm_invocation_parameter_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L683-L690)

```python
def get_llm_invocation_parameter_attributes(
    invocation_parameters: Optional[Union[str, Dict[str, Any]]],
) -> Mapping[str, AttributeValue]
```

### `get_llm_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L639-L642)

```python
def get_llm_model_name_attributes(
    model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_llm_output_message_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L701-L706)

```python
def get_llm_output_message_attributes(
    messages: Optional[Sequence[Message]],
) -> Mapping[str, AttributeValue]
```

### `get_llm_provider_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L627-L630)

```python
def get_llm_provider_attributes(
    provider: Optional[OpenInferenceLLMProvider],
) -> Mapping[str, AttributeValue]
```

### `get_llm_request_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L645-L648)

```python
def get_llm_request_model_name_attributes(
    request_model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_llm_response_model_name_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L651-L654)

```python
def get_llm_response_model_name_attributes(
    response_model_name: Optional[str],
) -> Mapping[str, AttributeValue]
```

### `get_llm_system_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L633-L636)

```python
def get_llm_system_attributes(
    system: Optional[OpenInferenceLLMSystem],
) -> Mapping[str, AttributeValue]
```

### `get_llm_token_count_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L801-L820)

```python
def get_llm_token_count_attributes(
    token_count: Optional[TokenCount],
) -> Mapping[str, AttributeValue]
```

### `get_llm_tool_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L823-L842)

```python
def get_llm_tool_attributes(
    tools: Optional[Sequence[Tool]],
) -> Mapping[str, AttributeValue]
```

### `get_metadata_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L434-L440)

```python
def get_metadata_attributes(
    *,
    metadata: Union[str, Dict[str, Any]],
) -> Dict[str, AttributeValue]
```

### `get_output_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L477-L497)

```python
def get_output_attributes(
    value: Any,
    *,
    mime_type: Optional[OpenInferenceMimeType] = None,
) -> Dict[str, AttributeValue]
```

### `get_reranker_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L195-L228)

```python
def get_reranker_attributes(
    *,
    query: Optional[str] = None,
    model_name: Optional[str] = None,
    input_documents: Optional[List[Document]] = None,
    output_documents: Optional[List[Document]] = None,
    top_k: Optional[int] = None,
) -> Dict[str, AttributeValue]
```

### `get_retriever_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L231-L243)

```python
def get_retriever_attributes(
    *,
    documents: List[Document],
) -> Dict[str, AttributeValue]
```

### `get_session_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L426-L427)

```python
def get_session_attributes(
    *,
    session_id: str,
) -> Dict[str, AttributeValue]
```

### `get_span_kind_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L447-L451)

```python
def get_span_kind_attributes(
    kind: OpenInferenceSpanKind,
    /,
) -> Dict[str, AttributeValue]
```

### `get_tag_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L430-L431)

```python
def get_tag_attributes(*, tags: List[str]) -> Dict[str, AttributeValue]
```

### `get_tool_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L540-L558)

```python
def get_tool_attributes(
    *,
    name: str,
    description: Optional[str] = None,
    parameters: Union[str, Dict[str, Any]],
) -> Dict[str, AttributeValue]
```

### `get_user_id_attributes`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L443-L444)

```python
def get_user_id_attributes(*, user_id: str) -> Dict[str, AttributeValue]
```

### `infer_llm_provider_from_host`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L169-L180)

```python
def infer_llm_provider_from_host(
    host: str,
) -> Optional[OpenInferenceLLMProviderValues]
```

Return the LLM provider name for the given API hostname.

### `infer_llm_system_from_model_name`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_attributes.py#L183-L192)

```python
def infer_llm_system_from_model_name(
    model_name: str,
) -> Optional[OpenInferenceLLMSystemValues]
```

Return the LLM system name for the given model identifier.

### `Annotation`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L62-L71)

```python
class Annotation(TypedDict)
```

A single annotation or evaluation result.

**Attributes**

| Name | Type and value |
| - | - |
| [`name`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.name) | `Required[str]` |
| [`score`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.score) | `Union[int, float]` |
| [`label`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.label) | `str` |
| [`explanation`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.explanation) | `str` |
| [`annotator_kind`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.annotator_kind) | `str` |
| [`identifier`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.identifier) | `str` |
| [`metadata`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Annotation.metadata) | `Union[str, Dict[str, Any]]` |

### `AnnotationScope`

_attribute_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L59)

```python
AnnotationScope: TypeAlias = Literal['span', 'trace', 'session']
```

### `DecisionTokenCount`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L132-L141)

```python
class DecisionTokenCount(TypedDict)
```

Token usage of a decision model call.

Decision models have no prompt/completion split: `input` counts the tokens sent (state, questions, and candidate options) and `output` the tokens in the typed answers. There is no total; it is the sum when both are present.

**Attributes**

| Name | Type and value |
| - | - |
| [`input`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.DecisionTokenCount.input) | `int` |
| [`output`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.DecisionTokenCount.output) | `int` |

### `Document`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L155-L159)

```python
class Document(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`content`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Document.content) | `str` |
| [`id`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Document.id) | `Union[str, int]` |
| [`metadata`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Document.metadata) | `Union[str, Dict[str, Any]]` |
| [`score`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Document.score) | `float` |

### `Embedding`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L150-L152)

```python
class Embedding(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Embedding.text) | `str` |
| [`vector`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Embedding.vector) | `List[float]` |

### `Image`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L74-L75)

```python
class Image(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`url`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Image.url) | `str` |

### `ImageMessageContent`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L84-L86)

```python
class ImageMessageContent(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`type`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ImageMessageContent.type) | `Literal['image']` |
| [`image`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ImageMessageContent.image) | `Image` |

### `Message`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L111-L116)

```python
class Message(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`role`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Message.role) | `str` |
| [`content`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Message.content) | `str` |
| [`contents`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Message.contents) | `Sequence[MessageContent]` |
| [`tool_call_id`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Message.tool_call_id) | `str` |
| [`tool_calls`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Message.tool_calls) | `Sequence[ToolCall]` |

### `MessageContent`

_attribute_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L97)

```python
MessageContent: TypeAlias = Union[TextMessageContent, ImageMessageContent, ReasoningMessageContent]
```

### `PromptDetails`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L119-L122)

```python
class PromptDetails(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`audio`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.PromptDetails.audio) | `int` |
| [`cache_read`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.PromptDetails.cache_read) | `int` |
| [`cache_write`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.PromptDetails.cache_write) | `int` |

### `ReasoningMessageContent`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L89-L94)

```python
class ReasoningMessageContent(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`type`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ReasoningMessageContent.type) | `Required[Literal['reasoning']]` |
| [`text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ReasoningMessageContent.text) | `str` |
| [`signature`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ReasoningMessageContent.signature) | `str` |
| [`data`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ReasoningMessageContent.data) | `str` |
| [`encrypted_content`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ReasoningMessageContent.encrypted_content) | `str` |

### `TextMessageContent`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L78-L81)

```python
class TextMessageContent(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`type`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TextMessageContent.type) | `Required[Literal['text']]` |
| [`text`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TextMessageContent.text) | `Required[str]` |
| [`signature`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TextMessageContent.signature) | `str` |

### `TokenCount`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L125-L129)

```python
class TokenCount(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`prompt`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TokenCount.prompt) | `int` |
| [`completion`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TokenCount.completion) | `int` |
| [`total`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TokenCount.total) | `int` |
| [`prompt_details`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TokenCount.prompt_details) | `PromptDetails` |

### `Tool`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L144-L147)

```python
class Tool(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`json_schema`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Tool.json_schema) | `Required[Union[str, Dict[str, Any]]]` |
| [`name`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Tool.name) | `str` |
| [`description`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.Tool.description) | `str` |

### `ToolCall`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L105-L108)

```python
class ToolCall(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`id`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ToolCall.id) | `str` |
| [`function`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ToolCall.function) | `ToolCallFunction` |
| [`reasoning_signature`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ToolCall.reasoning_signature) | `str` |

### `ToolCallFunction`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/_types.py#L100-L102)

```python
class ToolCallFunction(TypedDict)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`name`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ToolCallFunction.name) | `str` |
| [`arguments`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.ToolCallFunction.arguments) | `Union[str, Dict[str, Any]]` |

## `openinference.instrumentation.logging`

### `CustomFormatter`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/logging.py#L5-L9)

```python
class CustomFormatter(logging.Formatter)
```

#### `format`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/logging.py#L6-L9)

```python
def format(record: LogRecord) -> str
```

## `openinference.instrumentation.helpers`

### `get_span_id`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/helpers.py#L7-L8)

```python
def get_span_id(span: Span) -> str
```

### `get_trace_id`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/helpers.py#L11-L12)

```python
def get_trace_id(span: Span) -> str
```

## `openinference.instrumentation.config`

### `mask_without_externalization`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L565-L577)

```python
def mask_without_externalization(
    config: TraceConfig,
    key: str,
    value: Union[AttributeValue, Callable[[], AttributeValue]],
) -> Optional[AttributeValue]
```

Applies `config.mask` as a pure view — no blob-upload side effects. Falls back to the two-argument form for TraceConfig subclasses that override `mask` without the `externalize` keyword.

### `is_base64_url`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/config.py#L653-L656)

```python
def is_base64_url(url: str) -> bool
```
