> ## Documentation Index
> Fetch the complete documentation index at: https://arizeai-433a7140.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 05.01.2026 TanStack AI Tracing

> Instrument TanStack AI chat, tool-calling, and agent loops with the new @arizeai/openinference-tanstack-ai middleware.

**Available in @arizeai/openinference-tanstack-ai 0.1.0+**

Phoenix now ships an OpenInference middleware for [TanStack AI](https://tanstack.com/ai/latest/docs/getting-started/overview). Plug `openInferenceMiddleware()` into any `chat()` call to capture an `AGENT` span for the run, an `LLM` span for each model turn, and a `TOOL` span for every executed tool call — across both streaming and non-streaming flows, and across any TanStack AI provider adapter.

<Frame>
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/tanstack-ai.png" alt="TanStack AI traces in Phoenix" />
</Frame>

```bash theme={null}
npm install --save @arizeai/openinference-tanstack-ai @tanstack/ai
```

```typescript theme={null}
import { chat } from "@tanstack/ai";
import { openaiText } from "@tanstack/ai-openai";
import { openInferenceMiddleware } from "@arizeai/openinference-tanstack-ai";

const stream = chat({
  adapter: openaiText("gpt-4o-mini"),
  messages: [{ role: "user", content: "What is OpenInference?" }],
  middleware: [openInferenceMiddleware()],
});
```

<Note>
  This integration is brand new. If you run into issues or have ideas for improvements, please reach out via the [OpenInference repo](https://github.com/Arize-ai/openinference) — we'd love your feedback.
</Note>

<CardGroup cols={2}>
  <Card title="TanStack AI Tracing Docs" icon="book" href="/docs/phoenix/integrations/typescript/tanstack-ai/tanstack-ai-tracing">
    Setup, usage, and a tool-calling example.
  </Card>

  <Card title="TanStack AI" icon="globe" href="https://tanstack.com/ai/latest/docs/getting-started/overview">
    Learn more about TanStack AI.
  </Card>
</CardGroup>
