How to Use GitHub Copilot to Write Your First AI-Powered Application in 60 Minutes
How to Use GitHub Copilot to Write Your First AI-Powered Application in 60 Minutes
If you're like most indie hackers or solo founders, you've probably found yourself staring at a blank screen, wondering how to kickstart your first AI-powered application. The good news is that you can leverage GitHub Copilot to get you on your way in just 60 minutes. This isn't just theory; I’ve done it myself, and I’m here to share how you can do it too.
Prerequisites: What You Need Before Starting
Before you jump in, here’s what you need to have in place:
- GitHub Account: Sign up for a GitHub account if you don't already have one.
- Visual Studio Code (VS Code): Download and install VS Code.
- GitHub Copilot: Subscribe to GitHub Copilot ($10/month or $100/year as of May 2026). You’ll need to enable it in VS Code.
- Node.js: Install Node.js to run your application.
Step 1: Set Up Your Project
- Open VS Code.
- Create a new folder for your project and open it in VS Code.
- Open the terminal and run the following command to initialize a new Node.js project:
This creates anpm init -ypackage.jsonfile in your project directory.
Step 2: Install Necessary Packages
You’ll need a few libraries to make your AI application functional. For this tutorial, let’s build a simple chatbot. Run the following command in your terminal:
npm install express body-parser @openai/api
Step 3: Start Writing Code with GitHub Copilot
-
Create a new file called
app.js. -
Start typing the following:
const express = require('express'); const bodyParser = require('body-parser'); const app = express();As you type, GitHub Copilot will suggest completions. Accept its suggestions to build out the structure of your server.
-
Continue writing:
app.use(bodyParser.json()); app.post('/chat', (req, res) => { // AI chat logic here });Use Copilot to fill in the AI logic, and it will suggest how to integrate OpenAI's API.
-
Complete the logic for the AI chat:
const { Configuration, OpenAIApi } = require('@openai/api'); const configuration = new Configuration({ apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIApi(configuration); app.post('/chat', async (req, res) => { const userMessage = req.body.message; const response = await openai.createChatCompletion({ model: 'gpt-3.5-turbo', messages: [{ role: 'user', content: userMessage }], }); res.json({ reply: response.data.choices[0].message.content }); }); -
Start the server: At the end of your
app.js, add:app.listen(3000, () => { console.log('Server is running on http://localhost:3000'); });
Step 4: Test Your Application
- Run your app:
node app.js - Use a tool like Postman or Curl to test the
/chatendpoint. Send a POST request with a JSON body:{ "message": "Hello, AI!" }
Troubleshooting: What Could Go Wrong
- Copilot Suggestions Not Appearing: Ensure that GitHub Copilot is enabled in VS Code under Extensions.
- API Key Issues: Make sure you set your OpenAI API key in your environment variables. If you get a 401 error, your key might be invalid.
What's Next?
Once you have your basic AI chatbot up and running, consider adding features like user authentication, a database for storing chat logs, or even a front-end interface. You can also explore integrating more advanced AI models or even experimenting with different frameworks.
Conclusion: Start Here
If you’re an indie hacker looking to build something quickly, GitHub Copilot is a solid choice for getting your first AI application off the ground in just an hour. The key is to embrace the suggestions Copilot gives you while maintaining an understanding of your code.
What I recommend is to dive in, follow this guide, and see what you can create. It’s all about iterating and improving your application as you learn.
Follow Our Building Journey
Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.