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

Popular posts from this blog

Thrown Into the Azure River by AI — An AZ-104 Learning Story

Lecture 01 – Cloud Readiness & Digital Transformation: Understanding the Real Requirements

Lecture 02 – Foundations of Digital Transformation & Cloud Concepts