Skip to main content

AgentInterface

Agents shape UI. Not templates.

Agent GUIs without ceremony.

pip install agentinterface

Pattern

Agent text → Shaper LLM → Component JSON → React UI

Wrap any agent. Any LLM selects components. React renders UI.

Usage

from agentinterface import ai

def sales_agent(query: str) -> str:
    return "Q3 revenue: $2M, up 15%. Users: 10K."

enhanced = ai(sales_agent, llm="gemini")
text, components = await enhanced("Show Q3 dashboard")

# Returns:
# text: "Q3 revenue: $2M, up 15%. Users: 10K."
# components: [{"type": "card", "data": {"title": "Q3 Revenue", "value": "$2M"}}]

Works with sync, async, streaming agents.

LLM Providers

# String providers (defaults: gpt-4.1-mini, gemini-2.5-flash, claude-4.5-sonnet-latest)
ai(agent, llm="openai")
ai(agent, llm="gemini")
ai(agent, llm="anthropic")

# Custom models
from agentinterface.llms import OpenAI, Gemini, Anthropic
ai(agent, llm=OpenAI(model="gpt-4o"))
ai(agent, llm=Gemini(model="gemini-pro"))

# Custom LLM
from agentinterface.llms import LLM

class CustomLLM(LLM):
    async def generate(self, prompt: str) -> str:
        ...

ai(agent, llm=CustomLLM())

Composition

# Vertical stack
[card1, card2, card3]

# Horizontal grid
[[card1, card2, card3]]

# Mixed layout
[
  card1,              # Full width
  [card2, card3],     # Side by side
  table1              # Full width
]

Nested arrays = horizontal. Arrays = vertical.

Bidirectional Callbacks

from agentinterface.callback import Http

callback = Http()
enhanced = ai(agent, llm="gemini", callback=callback)

async for event in enhanced("Show sales dashboard"):
    if event["type"] == "component":
        components = event["data"]["components"]
        
        # User clicks → callback receives interaction
        interaction = await callback.await_interaction(timeout=300)
        
        # Agent continues based on interaction

Components talk back to agent. Conversational UI.

Custom Components

Create React component with metadata:

// src/ai/metric.tsx
export const Metric = ({ label, value, change }) => (
  <div>
    <span>{label}</span>
    <strong>{value}</strong>
    <span>{change}</span>
  </div>
);

export const metadata = {
  type: 'metric',
  description: 'Key performance metric with change indicator',
  schema: {
    type: 'object',
    properties: {
      label: { type: 'string' },
      value: { type: 'string' },
      change: { type: 'string', optional: true }
    },
    required: ['label', 'value']
  },
  category: 'content'
};

Run autodiscovery:

npx agentinterface discover

Component automatically available to shaper LLM.

Built-in Components

10 components: card table timeline accordion tabs markdown image embed citation suggestions

API

ai(agent, llm, components=None, callback=None, timeout=300)
protocol(components=None)
shape(text, context, llm)

Docs

Full documentation: github.com/iteebz/agentinterface

License

MIT

Release files for agentinterface 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentinterface 1.0.0
File Size Uploaded
agentinterface-1.0.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentinterface 1.0.0
File Interpreter ABI Platform
agentinterface-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / agentinterface-1.0.0.tar.gz

Download URL agentinterface-1.0.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
10d75e9b1c55751ca3dde278914083fd5d1b7dae4be0948eabbd0639cc7e05f8
BLAKE2b-256 checksum
How to use checksums
260ebee53efe408661aab8677ce0e24beeff5901b6a659853fce1379e1719358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0

Release files / agentinterface-1.0.0-py3-none-any.whl

Download URL agentinterface-1.0.0-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43cb8e43c6b3b65e98507a381739908d6b781bb1a017bb494e848152b29baa14
BLAKE2b-256 checksum
How to use checksums
62a44dc3f4dbfdf43d13e2071caacbbbd0286f8e5eaf56338cb738993203bb2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page