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
A user sends a POST request to the API.
FastAPI:
- Parses JSON body
- Validates input
- Routes to correct endpoint
The backend sends the prompt to a GPT4Free provider which:
- Generates AI response
- Returns text output
{
"success": true,
"prompt": "Explain async in Python",
"response": "Async allows non-blocking execution..."
}https://dev-ai-api.onrender.com
https://dev-ai-api.onrender.com/docs
POST /ask
{
"prompt": "Explain REST API"
}POST /explain-error
{
"error": "TypeError: list indices must be integers"
}POST /explain-code
{
"code": "def add(a,b): return a+b"
}POST /generate-tests
{
"code": "def multiply(a,b): return a*b"
}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())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));fastapi
uvicorn
g4f
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port $PORT
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