What Is an API?
An API is a controlled way for one application to communicate with another application.
API stands for Application Programming Interface. The name sounds technical, but the basic idea is simple.
Think of an API as a messenger
Your application sends a request. The API delivers that request to another service. The service processes it and sends a response back to your application.
The Basic Request Cycle
- A user enters information into your application.
- Your application prepares an API request.
- The request is sent to Gemini.
- Gemini processes the information.
- Gemini returns a response.
- Your application displays the result.
A Practical Example
Imagine that you build an email rewriting tool. The user enters an unfinished email and selects a professional tone.
Your application might send Gemini a request containing:
{
"instruction": "Rewrite this email professionally.",
"email": "hey just checking if you got my last message"
}
Gemini processes that request and returns something similar to:
Hello,
I wanted to follow up and confirm whether you received my
previous message.
Thank you.
Your application then places that response inside the results container for the user.
The Three Main Parts
1. Input
Input is the information provided by the user. It might be text, an image, a PDF, an audio recording, or application settings.
2. Processing
Your server prepares the input, sends it to the API, and waits for the response.
3. Output
Output is the result returned by Gemini and displayed inside your application.
The Foundation of an AI Application
Nearly every AI application can be reduced to this same basic structure: input → processing → output.
The API Is Not the Application
Gemini supplies intelligence, but it does not automatically create the finished application.
You still control:
- The interface
- The input fields
- The instructions
- The buttons
- The output format
- The user experience
- The security
- The usage limits
That distinction matters. The API is one component inside the application. It is not the entire product.
Important
An API key should normally remain on your server. Placing a private API key directly inside browser JavaScript can expose it to anyone who views the page source.
Lesson Summary
An API allows your application to communicate with an external service. In this course, our PHP application will send requests to Gemini and display the responses inside interfaces that we control.