Part 5: Making Predictions via REST API (JSON Input/Output) – RainPredict-AI
๐ Part 5: Making Predictions via REST API (JSON Input/Output)
Send Live Data to Your AI Model and Get Predictions from Vertex AI – Powered by Siraat AI Academy
In Part 5 of our RainPredict-AI series, we go from “trained & deployed” to “live and working” — by calling your model’s API endpoint with real-time weather data! ๐ฐ️ You’ll learn how to send JSON input and receive predictions using Google Cloud’s REST API tools.
This is your model’s first true test in the wild — and the final step before adding a user-friendly UI (coming in Part 6). Let's get started!
๐งฐ What You Need Before Starting
- ๐ข A trained AutoML Tabular model (from Part 3)
- ๐ข Deployed to Vertex AI Endpoint (from Part 4)
- ๐ข Your Project ID, Endpoint ID, and Service Account JSON key
- ๐ข curl installed OR use Postman for API testing
๐ Authenticate Your API Request
You must authenticate using a service account key file. Use the following command to get an auth token:
gcloud auth activate-service-account --key-file="your-key.json" gcloud auth print-access-token
☝️ Copy the token – you'll use it to call the API.
๐ค Send JSON Data to the API
Here's an example prediction request using curl:
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/us-central1/endpoints/YOUR_ENDPOINT_ID:predict \
-d '{
"instances": [
{
"temperature": 78,
"humidity": 60,
"pressure": 1015
}
]
}'
You’ll receive a response like:
{
"predictions": [0.42]
}
๐ฏ Boom! Your AI just predicted rainfall in real time.
๐งช Use Postman or Apps to Test (Optional)
- Import the endpoint URL into Postman
- Add
Authorization: Bearer <access-token> - Paste your JSON input
- Send → Receive predicted rainfall instantly!
๐ก Final Insights
- You’ve successfully triggered your AI model using REST API
- This approach can be integrated into ANY software, website, or app
- JSON makes it universal, and Google handles the scale
๐ฅ You’ve now reached the production edge of AI. Well done!
⏭️ Up Next: Part 6 – BONUS: Connecting to AppSheet or Cloud Run UI (Optional Frontend)
Now that you have live predictions, it’s time to build a frontend interface — even without coding! Use AppSheet or create a form in Cloud Run.
๐ฑ Ready to make it visual? Stay tuned for the bonus finale in Part 6!
Comments
Post a Comment