Daily AI recipesWorkVerified Jul 22, 2026

Create Your First AI Agent with Secure API Access

A working agent in 7 minutes with no paid services - just local code and free APIs

  1. 1.Install Node.js (if you don't have it). Open your terminal and run: node --version. If you see nothing - download from nodejs.org and install it.

    Node.js is free. Choose the LTS version.

    Node.js
  2. 2.Create a project folder. In your terminal, run: mkdir ai-agent && cd ai-agent && npm init -y

    Commands work the same on Windows (PowerShell), macOS, and Linux.

  3. 3.Install required packages: npm install axios dotenv. This will let your agent make API requests and store keys safely.

    All packages are free. They're downloaded from the npm repository.

    npm
  4. 4.Create a .env file in the ai-agent folder and add one of the free API keys. Option 1 (recommended for beginners): use Open-Meteo (free weather API, no registration needed). Option 2: get a free API key from OpenWeather (registration required, but a free tier exists). .env content for Open-Meteo: WEATHER_API=https://api.open-meteo.com/v1/forecast

    ⚠️ Never publish your .env file to git or the internet. Open-Meteo requires no key and is perfect for your first agent.

    Text Editor (VS Code)
  5. 5.Create a file named agent.js in the ai-agent folder and copy the code below into it. This agent will request weather by coordinates and output the result to your terminal.

    Use the same text editor.

    Text Editor (VS Code)
    Prompt
    require('dotenv').config();
    const axios = require('axios');
    
    async function weatherAgent(latitude, longitude) {
      try {
        const apiUrl = `${process.env.WEATHER_API}?latitude=${latitude}&longitude=${longitude}&current_weather=true`;
        const response = await axios.get(apiUrl);
        const weather = response.data.current_weather;
        console.log(`Temperature: ${weather.temperature}°C`);
        console.log(`Wind speed: ${weather.windspeed} km/h`);
        return weather;
      } catch (error) {
        console.error('Request error:', error.message);
      }
    }
    
    weatherAgent(55.7558, 37.6173);
    What this prompt doesThis code makes an agent that takes latitude and longitude, sends a request to the weather API, and outputs temperature and wind speed. The example uses Moscow coordinates (55.7558, 37.6173) - replace them with your own, or keep them for testing.
  6. 6.Run the agent in your terminal: node agent.js. You'll see the current temperature and wind speed for the coordinates you specified.

    If you get a 'require' error - make sure you're in the ai-agent folder (the pwd command will show your current folder).

  7. 7.Add security: create a file named security.js with input validation before sending to the API. Copy the line below into your agent before the request to validate coordinates:

    This step prevents sending incorrect data and protects against potential injections.

    Text Editor (VS Code)
    Prompt
    if (latitude < -90 || latitude > 90 || longitude < -180 || longitude > 180) {
      throw new Error('Coordinates are out of valid range');
    }
    What this prompt doesAdd this check to the beginning of the weatherAgent() function before the API request. It ensures latitude is between -90 and 90, and longitude is between -180 and 180, which protects your agent from incorrect input data.
💰 What it costs to followprices as of 2026-07
  • freeNode.jsCompletely free and open-source.
  • freenpm packages (axios, dotenv)All packages are free and open-source.
  • freeOpen-Meteo APIFree API with no request limits for personal use, no registration required.
  • freeFull recipeThe entire path is free - no credit card, paid subscriptions, or API credits needed.
Try it and be the first to check in

Why today

AI services change fast - interfaces and free limits may differ from what's described.