Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →You can build a basic AI chatbot in Python with OpenAI’s official Python SDK, an API key, and a short loop that sends each message to the Responses API. The first version can run in a terminal; from there, you can add conversation memory, a web interface, or retrieval from your own documents. The important design choice is that the model does not remember earlier requests unless your application supplies or stores that context.
What you need before you start
- Python 3.10 or later. The official OpenAI Python library lists Python 3.10+ as supported.
- An OpenAI API key, kept outside your source code.
- A model name currently supported by your API account. Model names and availability can change, so check the live API documentation when choosing one.
This tutorial starts with a command-line bot because it makes the model call and state handling visible without adding a web framework. OpenAI’s developer quickstart documents the first API request at Make your first API request.
Install the SDK and configure the API key
Create a project directory and, optionally, a virtual environment. Then install the SDK:
python -m venv .venv
# macOS or Linux
source .venv/bin/activate
# Windows PowerShell
.venvScriptsActivate.ps1
python -m pip install openai
Set the key and a model name in your shell environment rather than putting either value in the Python file. Set OPENAI_MODEL to a model that is currently available to your account.
#1 Best Overall
- Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
- Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit Low Noise Bearing System Fan
- Mega Heat Sink - Black Anodized
# macOS or Linux
export OPENAI_API_KEY="your-api-key"
export OPENAI_MODEL="your-current-supported-model"
# Windows PowerShell
$env:OPENAI_API_KEY="your-api-key"
$env:OPENAI_MODEL="your-current-supported-model"
The key is a secret credential: do not commit it to Git, paste it into a browser-side script, or include it in error logs. The SDK reads OPENAI_API_KEY automatically when you create an OpenAI() client.
Build a working Python chatbot loop
Save this as chatbot.py. It accepts text until you type exit or quit, sends each turn through the Responses API, and prints the returned text.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
model = os.environ["OPENAI_MODEL"]
while True:
user_text = input("You: ").strip()
if user_text.lower() in {"quit", "exit"}:
break
if not user_text:
continue
response = client.responses.create(
model=model,
input=user_text,
)
print("Bot:", response.output_text)
Run it with python chatbot.py. This smallest version treats each API request as a separate input: it does not pass the previous turn back to the model. That is enough to verify the key, SDK installation, model selection, and response printing. OpenAI’s SDK describes the Responses API as its primary API for interacting with models; its README also recommends starting with that API.
Rank #2
- Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
- Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
- CanaKit Premium High-Gloss Raspberry Pi 4 Case with Integrated Fan Mount, CanaKit Low Noise Bearing System Fan
- CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply (US Plug) with Noise Filter, Set of Heat Sinks, Display Cable - 6 foot (Supports up to 4K60p)
- CanaKit USB-C PiSwitch (On/Off Power Switch for Raspberry Pi 4)
Add conversation memory intentionally
“Memory” can mean keeping the last few turns during one session, preserving a thread across sessions, or making conversations available across devices. Choose the behavior you need instead of assuming the model will remember. The Responses API guide covers conversation state, including response chaining and the Conversations API.
| Approach | Persistence and effort | Control to consider |
|---|---|---|
| Replay selected history | Your application keeps a bounded list of user and assistant turns and sends it with each request. It is straightforward for a short-lived session. | You decide what to retain, remove, or truncate. Keep history bounded so requests do not grow without limit. |
Chain with previous_response_id |
Pass the prior response ID with the next request to continue a response chain. | Convenient state handling still requires an application decision about which ID belongs to which user and when to start a fresh chain. |
| Use a Conversations API object | Use a durable conversation identifier when the application needs a longer-lived conversation object. | Decide how to associate, protect, and expire conversation identifiers in your own product. |
For the terminal example, you can add a response chain with a small change:
previous_response_id = None
while True:
user_text = input("You: ").strip()
if user_text.lower() in {"quit", "exit"}:
break
if user_text.lower() == "/new":
previous_response_id = None
print("Started a new conversation.")
continue
if not user_text:
continue
response = client.responses.create(
model=model,
input=user_text,
previous_response_id=previous_response_id,
)
previous_response_id = response.id
print("Bot:", response.output_text)
Here, /new discards the local pointer so the next input starts a new chain. A real multi-user service must keep state per user or conversation rather than in one shared variable. OpenAI’s conversation-state documentation says response objects are retained for 30 days by default; review that guide and the current data-controls documentation before choosing a retention policy for sensitive or regulated information.
Rank #3
- 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
- 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
- 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
- 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
- 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
Make answers use your own documents
For a chatbot that answers from internal guides, policies, or product documentation, use retrieval-augmented generation rather than placing an entire document collection in every prompt. The pattern described in OpenAI’s Q&A and chatbot guidance is to retrieve relevant material and include it as context for the answer.
- Ingest: collect the documents the bot is allowed to use, preserve useful titles and section labels, and normalize their text.
- Chunk: split long material into sections small enough to retrieve and cite usefully. Chunk size and overlap depend on the structure of your corpus; evaluate them rather than treating one value as universal.
- Index: create an embedding for each section and store the vector alongside the text and source metadata in an index or vector database.
- Retrieve: embed the user’s question, search for the most relevant sections, and select only the context that can fit usefully in the request.
- Answer: include the selected passages with their source labels and instruct the model to answer from those sources, distinguish inference from evidence, and say when the supplied context does not answer the question.
- Evaluate: test representative questions, including questions with no answer in the corpus, conflicting passages, and stale content. Check retrieval quality and whether source labels point to the right material.
Embedding model, chunking rules, vector store, ranking thresholds, and update cadence are implementation decisions; there is no single setting established for every document set. Keep the retrieval stage observable so you can tell whether a bad answer came from missing or irrelevant retrieved text, or from the generated response. Refresh or remove indexed sections when the source documents change.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsPut the chatbot behind an interface
A terminal loop is a useful prototype, but a website or application should send messages to a server-side Python endpoint. That endpoint should authenticate the user as needed, associate the request with the right conversation state, call the model, and return the answer. The browser must never receive the API key. Keep the model call in a backend service and apply your own access, rate, and data-retention rules there.
Rank #4
- All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
- Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
- Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
- Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
- Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online
Streaming can show generated text incrementally instead of waiting for a full response. The SDK supports streaming and an asynchronous client for workloads with concurrent requests; those choices can change how your application handles partial output, cancellation, and errors. If the product requires low-latency audio or multimodal interactions, assess the Realtime API and its WebSocket interface rather than trying to force those interactions into a plain text loop.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your chatbot has a deployed web interface and you need a clean screenshot for a report, test record, or page review, ScreenshotNeo can capture the page with one API request. It is a website screenshot API and MCP server from ScreenshotNeo; the request below uses Python and saves the response body as an image. Replace the example URL with the public URL of your own chatbot interface. See the ScreenshotNeo API documentation for request options.
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
- Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; those steps can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. The response includes
X-Page-VerdictandX-Billedheaders. - An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- Not including the Raspberry Pi 5 (8GB), the Crowpi advanced version comes with the Raspberry Pi 5
- ELECROW Black Case for the Raspberry Pi 5, CrowPi is equipped with a 9-inch HD touchscreen along with a camera; All the regular components used in DIY electronics are packed into the CrowPi development board, such as LCD, LED matrix, buzzer, light sensor, PIR sensor, ultrasonic sensor, IR sensor, etc
- Raspberry Pi Sensors: The Crowpi raspberry pi 5 programming kit is jam-packed with lots of buttons such as 19 different sensors in a tidy easy to use package; You don't have to wait and wire things
- Build Quality: Solid ABS shell and well made components in one place make it strong and convenient to travel
- Programming Lessons: This raspberry pi 5 learning kit ships with step by step instructions and provides 21 lessons to take you through identifying components reading code and running it in the terminal
Prepare the chatbot for production
A successful local response proves the integration works for one path; it does not establish that the model is suitable for your users or workload. OpenAI’s deployment checklist recommends choosing a model using representative evaluations, monitoring misalignment, preparing for traffic increases and overload, and considering background or WebSocket modes where they fit.
- Evaluate before selecting: compare candidate models against realistic prompts and desired answers, including edge cases and unsupported questions.
- Handle failures: give the interface a useful response when a request fails or takes too long. Avoid displaying raw stack traces or credentials to users.
- Plan for traffic: add concurrency controls and a path for overload rather than assuming every request will complete instantly.
- Monitor responsibly: record enough operational information to diagnose failures and misalignment, while minimizing sensitive user content in logs. Use a safety identifier as advised by the deployment checklist.
- Choose a retention posture: understand the API’s response and conversation state behavior, then align your application’s saved history and deletion flow with the data you actually need.
API cost depends on the model, request volume, and the input and output sent; this tutorial does not establish a price estimate. Memory replay and retrieval both add input context, so measure representative requests and avoid sending irrelevant history or document chunks. For work that can complete outside an interactive turn, evaluate background processing rather than holding a user request open unnecessarily.
Troubleshooting common problems
| Symptom | Likely cause | What to check |
|---|---|---|
| The program raises a missing-key error. | OPENAI_API_KEY is not set in the environment used to launch Python. |
Set it in the same terminal or runtime, then restart the process. Do not paste the secret into committed code. |
| The SDK cannot be imported. | The package was installed in a different Python environment, or the virtual environment is not active. | Activate the environment and run python -m pip install openai with the same python executable used to launch the script. |
| The API rejects the model. | The configured model name may be unavailable or unsupported for the account or request. | Check the current model documentation and account availability, then update OPENAI_MODEL. |
| Later answers ignore earlier turns. | The application did not send history or a valid prior response ID. | Confirm that the same conversation’s state is supplied on each turn and that separate users do not share state accidentally. |
| The document bot gives unsupported or irrelevant answers. | Relevant passages may not have been indexed or retrieved, or the prompt may not constrain answers to the context. | Inspect retrieved sections and labels, test no-answer cases, and revise ingestion, chunking, or ranking based on those tests. |
| Users see errors or long waits. | Failures, overload, or the interaction mode may not be handled by the application. | Add server-side error handling and user-facing status, monitor failure patterns, and evaluate async, streaming, background, or WebSocket approaches against the actual workflow. |
Frequently Asked Questions
Can this chatbot run without an internet connection?
No. This implementation calls a hosted API, so the Python process needs network access to send requests and receive model responses.
Can I switch to another model later?
Yes. Keeping the model name in the OPENAI_MODEL environment variable lets you change the selection without editing the chatbot loop; verify that the replacement is currently supported for your account.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

