A demonstration CLI application showcasing the OpenAI SDK with agentic capabilities using UnJS tools.
- 🤖 AI-Powered Weather Assistant - Uses GPT-4.1-mini to understand natural language weather queries
- 🌍 Global Weather Data - Get current weather for any city worldwide via OpenWeatherMap API
- 🛠️ Smart Tool Usage - AI automatically decides when to call the weather API based on user questions
- ⚡ Modern Stack - Built with UnJS ecosystem tools (citty, consola, ofetch, unbuild)
- 📦 TypeScript - Fully typed for better development experience
- Node.js 18+
- pnpm
- OpenAI API key
- OpenWeatherMap API key
-
Clone and install dependencies:
pnpm install
-
Set up environment variables:
cp .env.example .env
Edit
.env
with your API keys:OPENAI_API_KEY=your_openai_api_key_here OPENWEATHERMAP_API_KEY=your_openweathermap_api_key_here
-
Run the demo:
pnpm start
Once started, the CLI will prompt you for a question. Try asking about weather in different cities:
- "What's the weather like in Tokyo?"
- "Is it raining in London right now?"
- "How warm is it in Miami today?"
- "Tell me about the weather in Paris"
The AI agent will:
- Understand your natural language query
- Determine if weather data is needed
- Call the OpenWeatherMap API if necessary
- Provide a conversational response with weather information
# Development with hot reload
pnpm dev
# Type checking
pnpm typecheck
# Build for production
pnpm build
- OpenAI SDK - GPT-4.1-mini with Responses API
- citty - Elegant CLI builder (UnJS)
- consola - Beautiful console output (UnJS)
- ofetch - HTTP client for API calls (UnJS)
- unbuild - TypeScript build tool (UnJS)
- OpenWeatherMap API - Weather data source
The demo showcases:
- Agentic behavior - AI decides when tools are needed
- Function calling - Weather API integration as an OpenAI tool
- Natural language processing - Conversational interface
- Error handling - Graceful API failure management
- Modern tooling - UnJS ecosystem demonstration
Get your API key from: https://platform.openai.com/api-keys
Get your free API key from: https://openweathermap.org/api
MIT