# @arizeai/openinference-tanstack-ai

**JavaScript · Integration**

OpenInference middleware for TanStack AI

- **Version**: 0.3.6
- **Peer dependencies**: `@tanstack/ai >=0.10.0`

[npm](https://www.npmjs.com/package/@arizeai/openinference-tanstack-ai) · [README](https://github.com/Arize-ai/openinference/blob/main/js/packages/openinference-tanstack-ai/README.md) · [Source](https://github.com/Arize-ai/openinference/tree/main/js/packages/openinference-tanstack-ai)

## Install

```sh
npm install @arizeai/openinference-tanstack-ai
```

## `@arizeai/openinference-tanstack-ai`

### `openInferenceMiddleware`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/js/packages/openinference-tanstack-ai/src/index.ts#L106)

```typescript
function openInferenceMiddleware(
  options?: OpenInferenceTanStackAIMiddlewareOptions,
): ChatMiddleware
```

Creates a TanStack AI middleware that emits OpenInference-compatible AGENT, LLM, and TOOL spans.

The middleware is intentionally stateful per chat request so it can shape a single agent run into a readable span tree while preserving LLM inputs and outputs in the form Phoenix expects.

### `OpenInferenceTanStackAIMiddlewareOptions`

_type alias_ · [Source](https://github.com/Arize-ai/openinference/blob/main/js/packages/openinference-tanstack-ai/src/types.ts#L16)

```typescript
type OpenInferenceTanStackAIMiddlewareOptions = 
```

Configuration for the TanStack AI middleware.

`tracer` lets consumers opt into a specific OTel tracer while still using the shared OpenInference span shaping in this package.
