AI Job Agent Backend is a FastAPI-based service that uses an LLM (OpenAI) to automatically generate answers for job application forms.
It works with a browser extension or frontend agent that extracts form fields from job application pages and sends them to this backend. The backend then generates appropriate answers using the user's profile and job context.
- FastAPI REST API
- AI-powered form answer generation
- Uses OpenAI GPT models
- Token-based authentication
- Basic rate limiting
- JSON structured responses
- CORS enabled for browser extensions
- Health monitoring endpoint
Browser Extension / Frontend
│
│ POST /generate
▼
AI Job Agent Backend (FastAPI)
│
▼
OpenAI GPT Model
│
▼
Generated Answers
ai-job-agent-backend/ │ ├── main.py ├── .env ├── requirements.txt └── README.md
- Python 3.9+
- FastAPI
- Uvicorn
- OpenAI API key
git clone https://github.com/YOUR_USERNAME/ai-job-agent-backend.git\ cd ai-job-agent-backend
python -m venv venv
source venv/bin/activate
Windows:
venv\Scripts{=tex}\activate{=tex}
pip install fastapi uvicorn python-dotenv openai pydantic
Or create a requirements.txt:
fastapi
uvicorn
python-dotenv
openai
pydantic
Then run:
pip install -r requirements.txt
Create a .env file in the project root.
OPENAI_API_KEY=your_openai_api_key
AGENT_API_TOKEN=your_secret_token
MODEL=gpt-4o-mini
ALLOWED_ORIGINS=chrome-extension://*
Variable Description
OPENAI_API_KEY OpenAI API key AGENT_API_TOKEN Token used for authenticating requests MODEL OpenAI model used for generation ALLOWED_ORIGINS Allowed origins for CORS
Start the FastAPI server:
uvicorn main:app --reload
Server runs at:
API documentation:
GET /health
Response:
{ "ok": true, "model": "gpt-4o-mini" }
POST /generate
Headers:
x-agent-token: YOUR_AGENT_API_TOKEN
Content-Type: application/json
Request Example:
{ "page_url": "https://jobs.company.com/apply", "profile": { "name": "John Doe", "skills": ["Python", "SQL", "FastAPI"] }, "fields": [ { "id": "q1", "label": "Why do you want to work here?", "tag": "textarea", "type": "text" } ], "job_context": "Backend software engineer role" }
Response:
{ "answers": { "q1": "I am interested in this role because it aligns with my backend engineering experience." } }
Requests must include:
x-agent-token
Otherwise the API returns:
401 Unauthorized
The backend enforces a simple in-memory rate limit:
1 request per 0.8 seconds per token
If exceeded:
429 Too Many Requests
The system instructs the model to:
- Be professional and concise
- Never invent credentials
- Use only provided profile data
- Return "NEEDS_USER" if a question requires user decision
- Choose best option for dropdown fields
Output format:
{ "field_id": "answer" }
Possible improvements:
- Redis rate limiting
- Resume parsing
- Vector search for profile knowledge
- Logging and monitoring
- OAuth authentication
- Multi-model support
MIT License