Skip to content

gggff123/dev-ai-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ DevAI API

🧠 AI-Powered Developer Assistant (GPT4Free + FastAPI)


Python FastAPI Render Status License


🚀 What Is DevAI API?

DevAI API is a lightweight REST API built using FastAPI and powered by GPT4Free.

It helps developers:

  • 🤖 Ask AI programming questions
  • 🐛 Explain error messages
  • 📖 Explain source code
  • 🧪 Generate unit tests
  • ⚡ Get fast JSON responses

It is designed to be:

  • Free
  • Simple
  • Easy to integrate into apps or tools

🧠 How It Works

1️⃣ Client Sends Request

A user sends a POST request to the API.

2️⃣ FastAPI Receives Request

FastAPI:

  • Parses JSON body
  • Validates input
  • Routes to correct endpoint

3️⃣ GPT4Free Processes Prompt

The backend sends the prompt to a GPT4Free provider which:

  • Generates AI response
  • Returns text output

4️⃣ API Returns JSON

{
  "success": true,
  "prompt": "Explain async in Python",
  "response": "Async allows non-blocking execution..."
}

🌍 Live API

https://dev-ai-api.onrender.com


📘 Interactive Documentation

https://dev-ai-api.onrender.com/docs


📡 API Endpoints

1️⃣ Ask AI

POST /ask

{
  "prompt": "Explain REST API"
}

2️⃣ Explain Error

POST /explain-error

{
  "error": "TypeError: list indices must be integers"
}

3️⃣ Explain Code

POST /explain-code

{
  "code": "def add(a,b): return a+b"
}

4️⃣ Generate Unit Tests

POST /generate-tests

{
  "code": "def multiply(a,b): return a*b"
}

🐍 Python Usage Example

import requests

url = "https://dev-ai-api.onrender.com/ask"
data = {"prompt": "Explain decorators in Python"}

response = requests.post(url, json=data)
print(response.json())

🌐 JavaScript Usage Example

fetch("https://dev-ai-api.onrender.com/ask", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Explain closures"
  })
})
.then(res => res.json())
.then(data => console.log(data));

📦 Requirements

fastapi
uvicorn
g4f

🚀 Deploy on Render

Build Command

pip install -r requirements.txt

Start Command

uvicorn app:app --host 0.0.0.0 --port $PORT

⚠ Disclaimer

GPT4Free providers may change, rate-limit, or become unavailable.

This project is for educational and experimental purposes.


⭐ Star this repo if you like it
🚀 Built for developers

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages