<!-- LLM_VERSION_INFO
FORMAT: text/markdown
CONTENT_TYPE: article
ORIGINAL_URL: https://streamlit.io/generative-ai
ALTERNATE_VERSION: generative-ai/index.html (text/html)
EXTRACTION_DATE: 2026-04-17T00:54:23.428Z

This is the markdown version with text-only content (images converted to alt-text).
For rich formatting with images, request the HTML version at: generative-ai/index.html
-->

## Build powerful generative AI apps

Thousands of developers use Streamlit as their go-to platform to experiment and build generative AI apps. Create, deploy, and share LLM-powered apps as fast as ChatGPT can compute!

[Try example code](https://llm-examples.streamlit.app/) [Deploy on Community Cloud](/content/cloud/index.html)

## Your LLM code playground

Play around with a few of Streamlit’s open source examples using LLMs.

- Build a chatbot  
- File Q&A with Anthropic  
- Search with Langchain  
- Langchain Quickstart App  
- Langchain - Blog Outline Generator App

```python
Copy
```

Chatbot · Streamlit

Built with Streamlit 🎈

[Fullscreen](https://llm-examples.streamlit.app/?utm_medium=oembed)

Chatbot

keyboard_double_arrow_left

- [Chatbot](https://llm-examples.streamlit.app/)
- [File Q&A](https://llm-examples.streamlit.app/File_Q&A)
- [Chat with search](https://llm-examples.streamlit.app/Chat_with_search)
- [Langchain Quickstart](https://llm-examples.streamlit.app/Langchain_Quickstart)
- [Langchain PromptTemplate](https://llm-examples.streamlit.app/Langchain_PromptTemplate)
- [Chat with user feedback](https://llm-examples.streamlit.app/Chat_with_user_feedback)

OpenAI API Key

Show password text

[Get an OpenAI API key](https://platform.openai.com/account/api-keys)  
[View the source code](https://github.com/streamlit/llm-examples/blob/main/Chatbot.py)

# 💬 Chatbot[Link to heading](https://llm-examples.streamlit.app/~/+/?embed=True\#chatbot)

🚀 A Streamlit chatbot powered by OpenAI

## Unlock your creativity with LLMs

-   
[**30 Days of AI**](https://30daysofai.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**AI Assistant**](https://demo-ai-assistant.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**MathGPT**](https://mathgpt.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**LLM examples**](https://llm-examples.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**Gita GPT**](https://gitagpt-bollingen.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**🦙💬 Llama 2 Chatbot**](https://llama2.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**🦜🔗 Quickstart App**](https://langchain-quickstart.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**KnowledgeGPT**](https://knowledgegpt.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**MRKL**](https://langchain-mrkl.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**Seo Chat Bot**](https://seo-chat-bot.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**Weebsugpt**](https://wvsu-mis-weebsugpt.streamlit.app/?ref=streamlit-io-gallery-null)

-   
[**Chat with the Streamlit docs, powered by LlamaIndex**](https://llamaindex-chat-with-docs.streamlit.app/?ref=streamlit-io-gallery-null)

## Works with everything in the AI ecosystem

Did you know...

## LLMs are genius at writing apps

Streamlit is a breeze for humans and AI alike. Just watch ChatGPT write a Streamlit app in a matter of seconds. It's pair programming like never before.

## FAQ

- ###### What is a Large Language Model (LLM)?

A large language model is a **kind of neural network** – so-called Transformer – with a **large number of parameters** and **trained on a huge corpus of natural language data** which enable general-purpose, programmable AI. LLMs cost **10-100s of millions of dollars** to train and include **100s of billions of parameters**, making them the most complex AI projects built by humanity.

- ###### Which LLMs work with Streamlit?

Any LLM with a python implementation or API call works with Streamlit. This includes popular open source and closed source models like [OpenAI](/content/9e4c23c9964e49908f330fccf15b8da9?pvs=25/index.html), LLaMa, Anthropic, PaLM, and other open source models such as the ones hosted on HuggingFace or built with Transformers.

- ###### How to obtain an OpenAI API key?

You can get your own OpenAI API key by following the following instructions * Go to [https://platform.openai.com/account/api-keys](https://platform.openai.com/account/api-keys). \* Click on the + Create new secret key button. \* Next, enter an identifier name (optional) and click on the Create secret key button.

- ###### How to load LLM API key in a Streamlit app

Then add your OpenAI API key as an environment variable in Streamlit Community Cloud: * At the lower right corner, click on < Manage app then click on the vertical "..." followed by clicking on Settings. * This brings the **App settings**, next, click on the Secrets tab and paste the API key into the text box. * Click Save Now, that we have the API key defined in secrets, it should now be automatically detected in-app from the `OPENAI_API_KEY` environment variable. This can be explicitly called via `st.secrets[“OPENAI_API_KEY”]`

- ###### How do I connect Streamlit to OpenAI?

You can use the OpenAI python library. Run `pip install openai streamlit`. Here’s a very simple example: `python import streamlit as st import openai openai.api_key = st.secrets.openai_api_key input = st.text_input("Ask a question") if st.button("Submit"): chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": input}]) st.write(chat_completion.choices[0].message.content)`

- ###### How do I connect Streamlit to an LLM?

You can connect any other LLM to Streamlit the same way you would connect to the LLM from any other Python application. Search for a python client or example code from the LLM, and adapt it to Streamlit similar to the example above. Another good option is to use LangChain, which maintains [integrations to a huge range of LLMs](https://python.langchain.com/en/latest/modules/models/llms/integrations.html) for Python.
