> ## 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.

# Building AI powered data apps in Python with Streamlit

> Learn how to integrate Streamlit with Thesys to create Generative UI apps, AI-powered dashboards, and interactive interfaces with Python.

With just a few lines of Python, you can build dynamic Streamlit dashboards, create low-code AI interfaces,
and scale to production faster - all while keeping the simplicity developers love about Streamlit.

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

## Visualizing data

<Steps>
  <Step title="Install Streamlit and Thesys">
    ```bash theme={null}
    pip install streamlit streamlit-thesys pandas
    ```
  </Step>

  <Step title="Create a new Streamlit app">
    ```python theme={null}
    import streamlit as st
    import pandas as pd
    import streamlit_thesys as thesys

    # Load some example data
    df = pd.read_csv("sales.csv")
    api_key = os.getenv("THESYS_API_KEY")

    st.title("Generative Visualizations with Thesys")
    # Generate a chart dynamically
    thesys.visualize(
      instructions="Show monthly sales as a line chart",
      data=df,
      api_key=api_key
    )

    ```
  </Step>

  <Step title="Run the app">
    ```bash theme={null}
    export THESYS_API_KEY=<your-api-key>
    streamlit run app.py
    ```
  </Step>
</Steps>

## Using the LLM API directly

Since Thesys is a OpenAI compatible API, you can use it with any OpenAI compatible library.

<Steps>
  <Step title="Installing dependencies">
    ```bash theme={null}
    pip install openai
    ```
  </Step>

  <Step title="Create a new Streamlit app">
    ```python theme={null}
    import os
    import openai
    import streamlit as st
    import streamlit_thesys as thesys

    client = openai.OpenAI(
        base_url="https://api.thesys.dev/v1",
        api_key=os.getenv("THESYS_API_KEY"))

    response = client.chat.completions.create(
        model="c1/anthropic/claude-sonnet-4/v-20250815",
        messages=[{"role": "user", "content": "Population trend in the US"}])

    st.title("Population trend in the US")
    thesys.render_reponse(response.choices[0].message.content)
    ```
  </Step>

  <Step title="Run the app">
    ```bash theme={null}
    export THESYS_API_KEY=<your-api-key>
    streamlit run app.py
    ```
  </Step>
</Steps>
