library(shiny)
library(shinychat)
library(bslib)
library(ellmer)
ui <- page_fillable(
chat_ui(
id = "chat",
messages = "your messages here"
),
fillable_mobile = TRUE
)
server <- function(input, output, session) {
chat <-
chat_openai(
base_url = "https://api.openai.com/v1",
model = "gpt-5.1",
api_key = your_api_key_here,
system_prompt = ""
)
observeEvent(input$chat_user_input, {
stream <- chat$stream_async(input$chat_user_input)
chat_append("chat", stream)
})
}
shinyApp(ui, server)

