Connect Autogen agents to Thesys to render interactive UIs, charts, and dynamic components instead of plain text responses.
This guide assumes you have basic knowledge of Python, Streamlit, and Autogen. You’ll also need a Thesys API key from the C1 Console.
1

Install dependencies

pip install -U "autogen-agentchat" "autogen-ext[openai]" "streamlit" "streamlit-thesys"
2

Configure Thesys model client

Create a model client that connects to Thesys API:
main.py
import asyncio
import os
import streamlit as st
import streamlit_thesys as thesys
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_core.models import ModelInfo

model_client = OpenAIChatCompletionClient(
    base_url="https://api.thesys.dev/v1/embed",
    api_key=os.getenv("THESYS_API_KEY"),
    model="c1/anthropic/claude-sonnet-4/v-20250815",
    model_info=ModelInfo(
        vision=False,
        function_calling=True,
        json_output=False,
        family="unknown",
        structured_output=True,
    ),
)
3

Create agent with tools

Define your agent with tools and system message:
main.py
# Define a simple function tool
async def get_weather(city: str) -> str:
    """Get the weather for a given city."""
    return f"The weather in {city} is 73 degrees and Sunny."

# Create the agent
agent = AssistantAgent(
    name="weather_agent",
    model_client=model_client,
    tools=[get_weather],
    system_message="You are a helpful assistant.",
    reflect_on_tool_use=True,
    model_client_stream=True,
)
4

Build Streamlit interface

Create a Streamlit app to run the agent and render responses:
main.py
async def main() -> None:
    st.title("Autogen Generative UI Chat")
    task = st.text_input("Enter a task:", value="What is the weather in New York?")

    if st.button("Run"):
        with st.spinner("Running..."):
            result = await agent.run(task=task)
            if result.messages:
                final_message = result.messages[-1]
                thesys.render_response(final_message.content)

    await model_client.close()

if __name__ == "__main__":
    asyncio.run(main())
5

Run the application

export THESYS_API_KEY=<your-api-key>
streamlit run main.py
Access your app at http://localhost:8501 to interact with your Autogen agent through Thesys-powered UI.

View the code

Find more examples and complete code on our GitHub repository.