> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thesys.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrating Autogen with Thesys

> Give your Autogen agents interactive UI components and dynamic workflows powered by Thesys C1

Connect Autogen agents to Thesys to render interactive UIs, charts, and dynamic components instead of plain text responses.

<Note>
  This guide assumes you have basic knowledge of Python, Streamlit, and Autogen.
  You'll also need a Thesys API key from the [C1 Console](https://console.thesys.dev/keys).
</Note>

<Steps>
  <Step title="Install dependencies">
    ```bash theme={null}
    pip install -U "autogen-agentchat" "autogen-ext[openai]" "streamlit" "streamlit-thesys"
    ```
  </Step>

  <Step title="Configure Thesys model client">
    Create a model client that connects to Thesys API:

    ```python main.py theme={null}
    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,
        ),
    )
    ```
  </Step>

  <Step title="Create agent with tools">
    Define your agent with tools and system message:

    ```python main.py theme={null}
    # 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,
    )
    ```
  </Step>

  <Step title="Build Streamlit interface">
    Create a Streamlit app to run the agent and render responses:

    ```python main.py theme={null}
    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())
    ```
  </Step>

  <Step title="Run the application">
    ```bash theme={null}
    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.
  </Step>
</Steps>

<Card title="View the code" icon="github" href="https://github.com/thesysdev/examples/tree/main/autogen">
  Find more examples and complete code on our GitHub repository.
</Card>
