# Streamlit

#### **What is Streamlit?** <a href="#what-is-streamlit" id="what-is-streamlit"></a>

Streamlit is an open-source Python library that allows you to create beautiful, interactive web applications for data science and machine learning projects without requiring front-end development skills (like HTML, CSS, or JavaScript).

In essence, it lets data scientists and ML engineers transform their data scripts, models, and analyses into shareable web apps very quickly and with minimal code.

**Sample implementation using nexos.ai**

* Install dependencies
* Define environments\
  `NEXOS_API_KEY=team-api-key`\
  `NEXOS_BASE_URL=https://api.nexos.ai/v1`.

```
import os
import streamlit as st

from openai import OpenAI
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()
# --- Configuration ---
NEXOS_BASE_URL = os.getenv("NEXOS_BASE_URL")
NEXOS_API_KEY = os.getenv("NEXOS_API_KEY")
if not NEXOS_BASE_URL or not NEXOS_API_KEY:
    raise ValueError("Please set NEXOS_BASE_URL and NEXOS_API_KEY in your .env file")

# Configure OpenAI client once, pointing to Nexos
client = OpenAI(
  api_key=NEXOS_API_KEY,
  base_url=NEXOS_BASE_URL # e.g. "https://api.nexos.ai/v1"
)

st.title("Chat via Nexos.ai")

user_input = st.text_input("Ask something:")

if user_input:
    try:
        response = client.chat.completions.create(
            model='Claude Haiku 4.5', # or any other OpenAI-compatible model ID available to you 
            messages=[{"role": "user", "content": user_input}]
        )
        st.write("Nexos Response:")
        st.write(response.choices[0].message.content)
    except Exception as e:
        st.error(f"Error calling Nexos: {e}")
```

You can use any open AI compatible model. To check what models are available for you, call [Gateway API | nexos.ai documentation](https://docs.nexos.ai/gateway-api#get-v1-models) You can use either `nexos_model_id`or `id` as model.

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nexos.ai/gateway-api/integrations/streamlit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
