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.ipynbto 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:7bmodel from Ollama and start it. You can do this by runningollama run deepseek-r1:7bin a terminal. -
Start the chat interface by opening
client/index.htmlin a browser. -
Start the text streaming server by first running
cd ~/api-tutorial/pythonin a terminal and thenpipenv run python3 text_streaming.py(or justpython3 text_streaming.pyif 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.