# Can A2UI Be Used with TensorFlow? A Framework-Agnostic Integration Guide

> Yes A2UI integrates with TensorFlow. Learn how to convert TensorFlow inference results into A2UI JSON payloads using the Python SDK with this framework agnostic guide.

- Repository: [Google/A2UI](https://github.com/google/A2UI)
- Tags: how-to-guide
- Published: 2026-03-13

---

**Yes, A2UI can be used with TensorFlow because it is a transport-agnostic JSON protocol that has no hard dependency on any machine learning library, allowing you to convert TensorFlow inference results into A2UI JSON payloads using the Python SDK.**

The `google/A2UI` repository provides a protocol for agent-to-agent user interfaces that operates independently of your backend technology. Since A2UI only defines a data format and helper utilities, you can integrate it with TensorFlow models, PyTorch, or even rule-based systems without modifying the core protocol.

## Why A2UI Works with Any ML Framework (Including TensorFlow)

A2UI is designed as a **transport-agnostic JSON protocol** that separates UI rendering from backend logic. This architecture means:

- **No framework dependencies**: The Python SDK in [`agent_sdks/python/src/a2ui/a2a.py`](https://github.com/google/A2UI/blob/main/agent_sdks/python/src/a2ui/a2a.py) contains only protocol utilities like `create_a2ui_part` and `is_a2ui_part`, with no imports from TensorFlow, PyTorch, or other ML libraries.
- **Pure data transformation**: Your backend performs inference using TensorFlow, then maps the output to A2UI's JSON schema describing components like cards, tables, or buttons.
- **Renderer independence**: The client-side renderer (such as the Lit implementation in [`renderers/lit/src/index.ts`](https://github.com/google/A2UI/blob/main/renderers/lit/src/index.ts)) consumes the JSON without knowledge of how the data was generated.

## How to Integrate TensorFlow with A2UI

Integrating TensorFlow with A2UI follows a three-step pipeline: inference, transformation, and transport packaging.

### Loading and Running Your TensorFlow Model

First, load your trained model using standard TensorFlow APIs. You can use `tf.keras.models.load_model` for Keras models or connect to TensorFlow Serving endpoints for production deployments.

```python
import tensorflow as tf

# Load a TensorFlow model (Keras or SavedModel format)

model = tf.keras.models.load_model("my_model/")

# Perform inference on input features

input_tensor = tf.constant([[0.2, 0.8, 0.5]])
predictions = model(input_tensor)
predicted_class = tf.argmax(predictions, axis=1).numpy()[0]

```

### Converting Predictions to A2UI JSON

Map your model's output to A2UI's component schema. The protocol supports various UI elements including `Card`, `Text`, `Button`, and `Table`.

```python

# Build an A2UI payload describing the UI to render

a2ui_payload = {
    "beginRendering": {
        "surfaceId": "tf-prediction-surface",
        "root": "prediction-card"
    },
    "components": [
        {
            "id": "prediction-card",
            "type": "Card",
            "title": "TensorFlow Prediction Result",
            "children": [
                {"type": "Text", "text": f"Predicted class: {predicted_class}"},
                {"type": "Button", "text": "View Details", "action": "showDetails"}
            ]
        }
    ]
}

```

### Using the Python SDK to Create Transportable Parts

Use the `create_a2ui_part` helper from [`a2ui/a2a.py`](https://github.com/google/A2UI/blob/main/a2ui/a2a.py) to wrap your JSON payload into a transportable A2A (Agent-to-Agent) message part.

```python
from a2ui.a2a import create_a2ui_part
from a2ui.core.schema.manager import A2uiSchemaManager

# Wrap the payload in an A2UI A2A Part

a2ui_part = create_a2ui_part(a2ui_payload)

# Optional: Validate against the A2UI schema

schema_manager = A2uiSchemaManager()
catalog = schema_manager.load_catalog("https://a2ui.org/specification/v0.9/basic_catalog.json")
catalog.validator.validate([a2ui_payload])

```

## Complete Code Example: TensorFlow to A2UI Integration

Here is the full integration pipeline combining TensorFlow inference with A2UI message generation:

```python
import tensorflow as tf
from a2ui.a2a import create_a2ui_part, parse_response_to_parts
from a2ui.core.schema.manager import A2uiSchemaManager

# 1️⃣ Load a TensorFlow model

model = tf.keras.models.load_model("my_model/")

# 2️⃣ Perform inference

input_tensor = tf.constant([[0.2, 0.8, 0.5]])
pred = model(input_tensor)
label = tf.argmax(pred, axis=1).numpy()[0]

# 3️⃣ Map prediction to A2UI JSON

a2ui_payload = {
    "beginRendering": {
        "surfaceId": "tf-prediction-surface",
        "root": "root-card"
    },
    "components": [
        {
            "id": "root-card",
            "type": "Card",
            "title": "TensorFlow Prediction",
            "children": [
                {"type": "Text", "text": f"Predicted class: {label}"},
                {"type": "Button", "text": "Ask for details", "action": "showDetails"}
            ]
        }
    ]
}

# 4️⃣ Create A2UI Part

a2ui_part = create_a2ui_part(a2ui_payload)

# 5️⃣ Validate against schema

schema_manager = A2uiSchemaManager()
catalog = schema_manager.load_catalog("https://a2ui.org/specification/v0.9/basic_catalog.json")
catalog.validator.validate([a2ui_payload])

# 6️⃣ Send to client (transport-specific)

# transport.send_parts([a2ui_part])

```

## Key Source Files and Architecture

Understanding the repository structure helps clarify why TensorFlow integration is seamless:

- **[`agent_sdks/python/src/a2ui/a2a.py`](https://github.com/google/A2UI/blob/main/agent_sdks/python/src/a2ui/a2a.py)**: Contains `create_a2ui_part` and `is_a2ui_part` utilities for packaging UI descriptions into transportable messages. No ML framework dependencies.
- **[`docs/specification/v0.9-a2ui.md`](https://github.com/google/A2UI/blob/main/docs/specification/v0.9-a2ui.md)**: Defines the formal JSON schema for UI components (Cards, Text, Buttons, Tables) that your TensorFlow backend should emit.
- **[`renderers/lit/src/index.ts`](https://github.com/google/A2UI/blob/main/renderers/lit/src/index.ts)**: Reference client-side renderer implementation that consumes A2UI JSON. Demonstrates that the client never inspects the backend technology.
- **[`samples/personalized_learning/README.md`](https://github.com/google/A2UI/blob/main/samples/personalized_learning/README.md)**: End-to-end example showing agent-based UI generation that can be adapted for TensorFlow model serving.

## Summary

- **A2UI is framework-agnostic**: The protocol in `google/A2UI` defines only a JSON data format and transport utilities, with no dependencies on TensorFlow or other ML libraries.
- **Integration requires data mapping**: Convert TensorFlow model outputs (from `tf.keras` or TensorFlow Serving) into A2UI JSON schemas describing UI components.
- **Use the Python SDK**: The `create_a2ui_part` function in [`agent_sdks/python/src/a2ui/a2a.py`](https://github.com/google/A2UI/blob/main/agent_sdks/python/src/a2ui/a2a.py) packages your JSON for transport via A2A, gRPC, or HTTP.
- **Client-side rendering is automatic**: Renderers like the Lit implementation consume the JSON without knowledge of the backend framework.

## Frequently Asked Questions

### Does A2UI require TensorFlow to function?

No. A2UI is a transport-agnostic JSON protocol with no hard dependencies on TensorFlow, PyTorch, or any other machine learning library. The Python SDK in [`agent_sdks/python/src/a2ui/a2a.py`](https://github.com/google/A2UI/blob/main/agent_sdks/python/src/a2ui/a2a.py) contains only protocol utilities for creating and validating UI message parts.

### What transport protocols does A2UI support with TensorFlow backends?

A2UI supports any transport that can carry JSON payloads, including A2A (Agent-to-Agent), gRPC, and HTTP. The `create_a2ui_part` helper generates message parts that are transport-agnostic, allowing your TensorFlow service to send UI descriptions through your existing infrastructure.

### Can I use A2UI with TensorFlow Serving?

Yes. You can deploy models via TensorFlow Serving, query the endpoint for predictions, and transform those predictions into A2UI JSON payloads. The integration point is purely data transformation—mapping TensorFlow Serving responses to the component schema defined in [`docs/specification/v0.9-a2ui.md`](https://github.com/google/A2UI/blob/main/docs/specification/v0.9-a2ui.md).

### Is there a specific A2UI TensorFlow SDK?

No. There is no separate SDK for TensorFlow integration. You use the standard Python SDK (`a2ui.a2a`) alongside TensorFlow's standard APIs (`tf.keras`, `tensorflow`). The `create_a2ui_part` function accepts dictionaries describing UI components, regardless of how you generated the data.