Today was the big integration day. The goal was to build the complete loop: user types in the browser -> Flask catches the message -> sends it to an AI model -> receives the generated text -> renders the answer on the web page.

1. The 2GB Download Trap vs. Fast APIs

We looked at two ways to connect an AI model: running it locally on your laptop with PyTorch and TinyLlama, or calling a cloud-hosted model like Qwen2.5-7B via the Hugging Face Inference API. Almost everyone tried downloading the local model. Within ten minutes, laptops were freezing, laptop fans were screaming, and downloads were crashing over the office Wi-Fi.

I skipped that headache entirely. I wrote a clean Python function using the 'requests' library to call Hugging Face's hosted inference endpoint with an authorization token. No 2GB download, no memory crashes, and answers came back in under half a second.

2. Getting Praised by Mentor Rashmi

When Rashmi came over to inspect my screen, she was amazed. While others were still waiting on pip installs, my chatbot was already having full conversations. She stopped the class and pointed out that real software engineering is about picking the right tool for the job. Why load gigabytes of weights onto a basic laptop when a lightweight API call gives you better results in milliseconds?

3. Catching Errors Safely

To make the chatbot reliable, we wrapped the network calls in try-except blocks. If the internet drops or the API rate-limits, the bot doesn't crash the server—it just returns a friendly message: 'Sorry, I couldn't reach the server right now. Try again in a moment!'

Key Learnings

  • Connecting a Flask backend to remote AI models using the Hugging Face Inference API.
  • The practical trade-offs: heavy local models vs lightweight, fast remote API calls.
  • Handling network exceptions with try-except blocks so the server never crashes.
  • Sanitizing AI outputs and stripping unwanted prompt prefixes before display.

Tools & Stack

  • Flask
  • Hugging Face API
  • Qwen2.5-7B
  • Python Requests

Challenges Overcome

  • Handling API rate limits when sending multiple quick messages.
  • Cleaning out model-generated system prompt artifacts from the returned text.

Task to be Performed

  • Set up a Flask route that handles incoming POST requests with user messages.
  • Send the prompt to the Hugging Face Inference API using secure headers.
  • Wrap network calls in error handling blocks to protect against connection failures.

Related Logs

Day 00

Day 00: Onboarding, Orientation, and the 2-Week AI Roadmap

Walking into Virtual Height for day zero: getting our badges, meeting our lead mentors, and mapping out what we will build over the next two weeks.

May 29, 2026 • 4 min readRead Log ➔
Day 01

Day 01: First Day as an AI Intern, Python Basics, and a Wild Flex

Day 1 kicks off with lead mentor Rashmi. We break down AI vs ML vs Deep Learning, test Python terminal scripts, and demo my custom chatbot to the room.

Jun 01, 2026 • 4 min readRead Log ➔