This is a collection of tutorials and demos about AI Web APIs.
The basic tutorial is in the python/tutorial.ipynb
file. It is a Jupyter notebook that can be run in a Jupyter environment. It demonstrates how to use the remove OpenAI API to generate text.
-
To use, you need to have a OpenAI API key. You can get one from https://platform.openai.com/api-keys.
-
Follow the instructions in the Jupyter notebook file
python/tutorial.ipynb
to run the tutorial. You can open it in a Jupyter environment or use an IDE like VSCode that supports Jupyter notebooks.
The directory client
contains a simple browser client that allows you prompt a local chat AI model and get the responses as a stream of text. The server for it is in the python/text_streaming.py
file.
-
To use the text streaming server, you need to have Ollama installed and running. You can get it from https://ollama.ai/.
-
You need to download the
deepseek-r1:7b
model from Ollama and start it. You can do this by runningollama run deepseek-r1:7b
in a terminal. -
Start the chat interface by opening
client/index.html
in a browser. -
Start the text streaming server by first running
cd ~/api-tutorial/python
in a terminal and thenpipenv run python3 text_streaming.py
(or justpython3 text_streaming.py
if not using a virtual environment).
There's also an audio streaming server, which is currently commented out in the client code because the TTS service is slow in its current configuration.