Close Menu
    Facebook LinkedIn YouTube WhatsApp X (Twitter) Pinterest
    Trending
    • Your RAG Gets Confidently Wrong as Memory Grows – I Built the Memory Layer That Stops It
    • Ancient parrot feathers reveal vast Andes trade routes
    • After building global startup, two founders who met at uni are backing a new generation of Kiwi students
    • This Scammer Used an AI-Generated MAGA Girl to Grift ‘Super Dumb’ Men
    • Arizona court battle against Kalshi slows amid legal scope disputes
    • Today’s NYT Connections Hints, Answers for April 21 #1045
    • High-Endurance ASW and Strike USV
    • The competition watchdog just got a seat at the table in the legal battle between Epic Games and Apple
    Facebook LinkedIn WhatsApp
    Times FeaturedTimes Featured
    Tuesday, April 21
    • Home
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    • More
      • AI
      • Robotics
      • Industries
      • Global
    Times FeaturedTimes Featured
    Home»Artificial Intelligence»I Finally Built My First AI App (And It Wasn’t What I Expected)
    Artificial Intelligence

    I Finally Built My First AI App (And It Wasn’t What I Expected)

    Editor Times FeaturedBy Editor Times FeaturedMarch 13, 2026No Comments15 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr WhatsApp Email
    Share
    Facebook Twitter LinkedIn Pinterest Telegram Email WhatsApp Copy Link


    everybody’s speaking about AI apps, however nobody actually reveals you what’s occurring behind the scenes? Yeah… that was me a couple of weeks in the past — looking at my display screen, questioning if I’d ever truly construct one thing that talked again.

    So, I made a decision to simply dive in, determine it out, and share all the pieces alongside the way in which. By the top of this publish, you’ll see precisely what occurs whenever you construct your first AI app, and also you’ll decide up a couple of actual expertise alongside the way in which: calling APIs, dealing with setting variables, and working your first script with out breaking something (hopefully).

    Let’s get into it — I promise it’s less complicated than it seems to be.

    What Are We Constructing — and Why It Really Issues

    Okay, so earlier than we begin typing code like maniacs, let’s pause for a second and discuss what we’re truly constructing right here. Spoiler: it’s not some sci-fi stage AI that can take over your job (but). It’s one thing sensible, real-world, and completely doable in a single afternoon: an AI-powered article summarizer.

    Right here’s the thought: you paste a bit of textual content — possibly a information article, a analysis paper, or perhaps a tremendous lengthy weblog publish — and our little AI app spits out a brief, easy-to-read abstract. Consider it as your private TL;DR machine. 

    Why this issues:

    • It’s instantly helpful: Anybody who reads plenty of content material (so… principally all of us on TDS) will love having a instrument that distills data immediately.
    • It’s easy, however highly effective: We’re solely making one API name, however the result’s a working AI app you possibly can truly showcase.
    • It’s expandable: Right this moment, it’s a command-line script. Tomorrow, you could possibly hook it as much as Slack, an internet interface, or batch-process tons of of articles.

    So yeah, we’re not reinventing the wheel — however we are demystifying what truly occurs behind the scenes whenever you construct an AI app. And extra importantly, we’re doing it in public, studying as we go, and documenting each little step in order that by the point you end this publish, you’ll truly perceive what’s occurring beneath the hood.

    Subsequent, we’ll get our arms soiled with Python, set up the OpenAI package deal, and set all the pieces up in order that our AI can begin summarising textual content. Don’t fear , I’ll clarify each single line as we go.

    Putting in the OpenAI Package deal (And Making Positive Nothing Breaks)

    Alright. That is the half the place issues normally really feel “technical” and barely intimidating.

    However I promise — we’re simply putting in a package deal and working a tiny script. That’s it.

    First, be sure you have Python put in. When you’re unsure, open your terminal (or Command Immediate on Home windows) and run:

    python --version

    When you see one thing like Python 3.x.x, you’re good. If not… set up Python first and are available again.

    Now let’s set up the OpenAI package deal. In your terminal:

    pip set up openai

    That command principally tells Python: “Hey, go seize this library from the web so I can use it in my challenge.”

    If all the pieces goes properly, you’ll see a bunch of textual content scroll by and ultimately one thing like:

    Efficiently put in openai

    That’s your first small win.

    Fast Actuality Test: What Did We Simply Do?

    After we ran pip set up openai, we didn’t “set up AI.” We put in a shopper library — a helper instrument that allows our Python script to speak with OpenAI’s servers.

    Consider it like this:

    • Your laptop = the messenger
    • The OpenAI API = the mind within the cloud

    The openai package deal = the language translator between them
    With out the package deal, your script wouldn’t know easy methods to correctly format a request to the API.

    Let’s Take a look at That It Works

    Earlier than we transfer ahead, let’s affirm Python can truly see the package deal.

    Run this:

    python

    Then contained in the Python shell:

    import openai
    print("It really works!")

    When you don’t see any indignant crimson error messages, congratulations — your setting is prepared.

    This will appear small, however this step teaches you one thing necessary:

    • The way to set up exterior libraries
    • How Python environments work
    • The way to confirm that your setup is appropriate

    These are foundational expertise. Each real-world AI or information challenge begins precisely like this.

    Subsequent, we’ll arrange our API key securely utilizing setting variables.

    Setting Up Your API Key (With out Unintentionally Leaking It)

    Okay. This half is necessary.

    To speak to the OpenAI API, we want one thing known as an API key. Consider it as your private password that claims, “Hey, it’s me — I’m allowed to make use of this service.”

    Now right here’s the error learners (together with previous me) make:

    They copy the API key and paste it immediately into the Python file. Please don’t try this.

    When you ever add that file to GitHub, share it publicly, and even ship it to a good friend, you’ve principally uncovered your secret key to the web. And sure — individuals and bots actively scan for that.

    So as an alternative, we’re going to retailer it safely utilizing setting variables.

    Step 1: Get Your API Key

    1. Create an account on OpenAI.
    2. Generate an API key out of your dashboard.
    3. Copy it someplace secure (for now).

    Don’t fear — we’re not placing it into our code.

    Step 2: Set the Atmosphere Variable

    On Home windows (Command Immediate):

    setx OPENAI_API_KEY "your_api_key_here"

    On Mac/Linux:

    export OPENAI_API_KEY="your_api_key_here"

    After working this, shut and reopen your terminal so the change takes impact.

    What we simply did: we created a variable saved in your system that solely your machine is aware of about.

    Step 3: Entry It in Python

    Now let’s affirm Python can see it.

    Open Python once more:

    python

    Then sort:

    import os
    api_key = os.getenv("OPENAI_API_KEY")
    print(api_key[:4] + "...")

    When you see the primary few characters of your key, which means all the pieces labored.

    And if None reveals up? That simply means the setting variable didn’t register — normally mounted by restarting your terminal.

    What’s Really Occurring Behind the Scenes?

    After we use os.getenv("OPENAI_API_KEY"), Python is solely asking your working system:

    “Hey, do you’ve got a variable saved beneath this title?”

    If it exists, it returns the worth. If not, it returns None.

    This tiny step introduces an enormous real-world idea:

    • Safe configuration administration
    • Separating secrets and techniques from code
    • Writing production-safe scripts

    That is how actual functions deal with credentials. You’re not simply constructing a toy app anymore. You’re following precise engineering finest practices.

    Subsequent, we’ll lastly make our first API name — the second the place your script sends textual content to the cloud… and one thing clever comes again.

    Making Your First API Name (This Is the Magic Second)

    Alright. That is it.

    That is the second the place your laptop truly talks to the AI.

    Up till now, we’ve simply been getting ready the setting. Putting in packages. Setting keys. Doing the “accountable grownup” setup work.

    Now we lastly ship a request.

    Create a brand new file known as app.py and paste this in:

    import os
    from openai import OpenAI
    
    shopper = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
    
    text_to_summarize = """
    Synthetic intelligence is reworking industries by automating duties,
    enhancing decision-making, and enabling new services.
    Nonetheless, understanding how these techniques work behind the scenes
    stays a thriller to many learners.
    """
    
    response = shopper.chat.completions.create(
    mannequin="gpt-4o-mini",
    messages=[
    {"role": "system", "content": "You are a helpful assistant that summarizes text clearly and concisely."},
    {"role": "user", "content": f"Summarize this text:
    {text_to_summarize}"}
    ]
    )
    print(response.decisions[0].message.content material)

    Now go to your terminal and run:

    python app.py

    And if all the pieces is ready up appropriately… you need to see a clear abstract printed in your terminal.

    Pause for a second when that occurs. As a result of what simply occurred is form of wild.

    Let’s Break Down What Simply Occurred

    Let’s stroll via this slowly.

    from openai import OpenAI

    This imports the shopper library we put in earlier. It’s the bridge between your script and the API.

    shopper = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

    Right here, we create a shopper object and authenticate utilizing the setting variable we set earlier.

    If the secret is mistaken. The request fails.
    If the secret is appropriate. You’re formally related.

    response = shopper.chat.completions.create(...)

    That is the API name.

    Your script sends:

    • The mannequin title
    • A listing of messages (structured like a dialog)
    • OpenAI’s servers course of it.
    • The mannequin generates a response.
    • The server sends structured JSON again to your script.

    Then we extract the precise textual content with:

    response.decisions[0].message.content material

    That’s it.

    Only a correctly formatted HTTP request going to a cloud server and a structured response coming again.

    Why This Is a Huge Deal

    You simply discovered easy methods to:

    • Authenticate with an exterior service
    • Ship structured information to an API
    • Obtain and parse structured output
    • Execute a full AI-powered workflow in beneath 30 strains of code

    That is the muse of actual AI functions.

    Subsequent, we’ll dig into what that response object truly seems to be like — as a result of understanding the construction is what separates copying code from truly realizing what’s happening.

    It Labored… After a Small (Very Actual) Actuality Test

    Earlier than we transfer on, I have to let you know what occurred the primary time I ran this.

    • The code was appropriate.
    • The API key was appropriate.
    • The request construction was appropriate.

    After which I bought this:

    openai.RateLimitError: 429
    'insufficient_quota'

    At first look, that feels scary.

    However right here’s what it truly meant:

    My script efficiently related to the API. The authentication labored. The server obtained my request.

    I simply didn’t have billing enabled. That’s it.

    Utilizing the API isn’t the identical as utilizing ChatGPT in your browser. The API is infrastructure. It runs on cloud sources. And people sources value cash.

    So I added a small quantity of credit to my account (nothing loopy — simply sufficient to experiment), ran the very same script once more…

    And it labored.

    Clear abstract printed to the terminal. No code modifications.

    That second is necessary. As a result of now we will categorize newbie API points into two principal buckets:

    • Code issues → Your Python script is invalid.
    • Infrastructure issues → Authentication, quota, or billing points.

    When you perceive that distinction, AI improvement turns into means much less mysterious.

    Now… What Does response Really Look Like?

    When your script works, response isn’t simply textual content. It’s a structured object (principally JSON beneath the hood).

    When you quickly print the entire thing:

    print(response)

    You’ll see one thing structured with fields like:

    id
    mannequin
    utilization
    decisions

    The precise abstract lives inside:

    response.decisions[0].message.content material

    Let’s unpack that:

    decisions → an inventory of generated outputs
    [0] → we’re grabbing the primary one
    message → the assistant’s reply object
    content material → the precise textual content

    This issues greater than it appears.

    As a result of in real-world functions, you would possibly:

    • Log token utilization for value monitoring
    • Retailer responses in a database
    • Deal with a number of decisions
    • Add correct error dealing with

    Proper now we’re simply printing the content material.

    However structurally, you now perceive easy methods to navigate an API response.

    And that’s the distinction between copying code… and truly realizing what’s happening.

    At this level, you’ve:

    • Put in a production-grade shopper library
    • Secured credentials correctly
    • Despatched a structured API request
    • Understood how billing and quota have an effect on infrastructure
    • Parsed structured output

    That’s a full AI workflow.

    Subsequent, we’ll make this barely extra interactive — as an alternative of hardcoding textual content, we’ll let the person paste in their very own article to summarize.

    And that’s when it actually begins feeling like an actual app.

    Making It Interactive (Your TL;DR App, Lastly!)

    Up till now, we’ve been doing all the pieces with a hardcoded chunk of textual content. That’s tremendous for testing, however it’s not very… you already know… app-like.

    We need to truly let a person paste in any article and get a abstract.

    Let’s repair that.

    Step 1: Get Consumer Enter

    Python makes this tremendous simple with the enter() operate. Open your app.py and change your text_to_summarize variable with this:

    text_to_summarize = enter("Paste your article right here:n")

    That’s it. Now, whenever you run:

    python app.py

    The terminal will wait so that you can paste one thing in. You hit Enter, and the AI does its factor.

    Step 2: Print the Abstract Properly

    As a substitute of dumping uncooked textual content, let’s make it a bit of prettier:

    abstract = response.decisions[0].message.content material
    print("nHere’s your abstract:n")
    print(abstract)

    See what we did there?

    We retailer the output in a variable known as abstract — helpful if we need to use it later.

    We add a bit of heading to make it apparent what the AI returned.

    This tiny contact makes your app really feel extra “completed” with out truly being fancy.

    Step 3: Take a look at It Out

    Run the script, paste in a paragraph from any article, and watch the magic occur:

    python app.py

    It’s best to see your customized abstract pop up in seconds.

    For this reason we began with a easy hardcoded string — now you possibly can truly work together with the mannequin like an actual app person.

    Step 4: Elective Extras (If You’re Feeling Fancy)

    If you wish to take it one step additional, you possibly can:

    • Loop till the person quits — allow them to summarize a number of articles with out restarting the script.
    • Save summaries to a file — helpful for analysis or weblog prep.
    • Deal with empty enter — make certain the app doesn’t crash if the person by chance hits Enter.

    Sprucing the App for Longer Articles

    Alright, by now our little AI summarizer works. You paste textual content, hit Enter, and get a abstract. 

    However there’s a small drawback: what occurs if somebody pastes a tremendous lengthy article, like a 2,000-word weblog publish?

    If we ship that on to the API, one in every of two issues normally occurs:

    The mannequin would possibly truncate the enter and solely summarize a part of it.
    The request might fail, relying on token limits.

    Not preferrred. So let’s make our app smarter.

    Step 1: Trim and Clear the Enter

    Even earlier than worrying about size, we must always tidy up the textual content.

    Take away pointless whitespace, newlines, or invisible characters:

    text_to_summarize = text_to_summarize.strip().change("n", " ")

    strip() removes additional areas firstly/finish
    change("n", " ") turns line breaks into areas so the mannequin sees a steady paragraph

    Small step, however it makes summaries cleaner.

    Step 2: Chunk Lengthy Textual content

    Let’s say we need to break up articles into smaller chunks so the mannequin can deal with them comfortably. A easy strategy is splitting by sentences or paragraphs. Right here’s a fast instance:

    max_chunk_size = 500 # roughly 500 phrases
    chunks = []
    phrases = text_to_summarize.break up()
    for i in vary(0, len(phrases), max_chunk_size):
    chunk = " ".be a part of(phrases[i:i+max_chunk_size])
    chunks.append(chunk)

    Now chunks is an inventory of manageable textual content items.

    We are able to then loop via every chunk, summarize it, and mix the summaries on the finish.

    Step 3: Summarize Every Chunk

    Right here’s how that may look:

    final_summary = ""
    for chunk in chunks:
    response = shopper.chat.completions.create(
    mannequin="gpt-4o-mini",
    messages=[
    {"role": "system", "content": "You are a helpful assistant that summarizes text clearly and concisely."},
    {"role": "user", "content": f"Summarize this text:n{chunk}"}
    ]
    )
    final_summary += response.decisions[0].message.content material + " "

    Discover how small the change is? However now, even tremendous lengthy articles may be summarized with out breaking the app.

    Step 4: Current a Clear Output

    Lastly, let’s make the outcome simple to learn:

    print("nHere’s your last abstract:n")
    print(final_summary.strip())

    .strip() on the finish ensures no additional areas or trailing newlines.

    The person sees one clear, steady abstract as an alternative of a number of disjointed outputs.

    From Concept to Actual AI App

    Once I began this, it was only a easy thought:

    “What if I might paste an article and immediately get a clear abstract?”

    That’s just about it. No large startup imaginative and prescient and complicated structure.

    And step-by-step, right here’s what occurred:

    • I put in an actual manufacturing library.
    • I discovered how APIs truly work.
    • I dealt with billing errors and setting variables.
    • I constructed a working CLI instrument.
    • Then I turned it into an internet app anybody can use.

    Someplace alongside the way in which, this stopped feeling like a “toy script.”
    It turned an actual AI workflow:

    Native machine → API name → cloud mannequin → structured response → person interface.

    And one of the best half? I perceive each piece of it now.

    The errors and warnings additionally helped. As a result of constructing in public forces you to decelerate, debug correctly, and truly be taught what’s occurring.

    That is how actual AI expertise are constructed. Not by memorizing code. However by transport small issues, breaking them, fixing them, and understanding them.

    So if this helped you, don’t cease right here.

    Break it. Enhance it.

    Add file uploads. Deploy it. Flip it right into a Chrome extension. Construct the model you would like existed.

    And in the event you do — write about it.

    As a result of the quickest technique to develop in AI proper now isn’t consuming content material.

    It’s constructing in public.

    And at this time, we shipped!

    I additionally deployed the app so you possibly can try it yourself here

    When you loved this text. Let me know. Would love your feedback and suggestions.

    Medium

    LinkedIn

    Twitter

    YouTube



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Editor Times Featured
    • Website

    Related Posts

    Your RAG Gets Confidently Wrong as Memory Grows – I Built the Memory Layer That Stops It

    April 21, 2026

    The LLM Gamble | Towards Data Science

    April 21, 2026

    Context Payload Optimization for ICL-Based Tabular Foundation Models

    April 21, 2026

    What Does the p-value Even Mean?

    April 20, 2026

    From Risk to Asset: Designing a Practical Data Strategy That Actually Works

    April 20, 2026

    Will Humans Live Forever? AI Races to Defeat Aging

    April 20, 2026

    Comments are closed.

    Editors Picks

    Your RAG Gets Confidently Wrong as Memory Grows – I Built the Memory Layer That Stops It

    April 21, 2026

    Ancient parrot feathers reveal vast Andes trade routes

    April 21, 2026

    After building global startup, two founders who met at uni are backing a new generation of Kiwi students

    April 21, 2026

    This Scammer Used an AI-Generated MAGA Girl to Grift ‘Super Dumb’ Men

    April 21, 2026
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    About Us
    About Us

    Welcome to Times Featured, an AI-driven entrepreneurship growth engine that is transforming the future of work, bridging the digital divide and encouraging younger community inclusion in the 4th Industrial Revolution, and nurturing new market leaders.

    Empowering the growth of profiles, leaders, entrepreneurs businesses, and startups on international landscape.

    Asia-Middle East-Europe-North America-Australia-Africa

    Facebook LinkedIn WhatsApp
    Featured Picks

    Check Your CGM: Recalled FreeStyle Libre 3 Sensors Associated With 7 Deaths

    February 5, 2026

    Malta Gaming Authority investigates system breach and warns against illegal sites

    March 18, 2026

    Everything Amazon Announced Today at Its Fall Hardware Event (2025)

    October 1, 2025
    Categories
    • Founders
    • Startups
    • Technology
    • Profiles
    • Entrepreneurs
    • Leaders
    • Students
    • VC Funds
    Copyright © 2024 Timesfeatured.com IP Limited. All Rights.
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us

    Type above and press Enter to search. Press Esc to cancel.