Skip to content
Mojib-RsmPublic

About

A lightweight PHP AI chatbot powered by OpenAI API with conversation memory, responsive UI, and easy deployment.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

PHP AI Agent 🤖

A lightweight, modern AI chatbot built with PHP and powered by the OpenAI API. Create your own AI assistant with a responsive chat interface, conversation memory, and simple deployment.

PHP OpenAI JavaScript License

✨ Features

  • 🤖 AI-powered conversations using OpenAI API
  • 💬 Modern ChatGPT-inspired chat interface
  • 🧠 Session-based conversation memory
  • 📱 Responsive mobile-friendly design
  • ⚡ Lightweight PHP backend
  • 🔄 Start a new conversation anytime
  • 🌐 Supports multiple languages
  • 🎨 Modern dark-themed UI
  • 🔐 Server-side API key configuration
  • 🚀 Easy installation and deployment

🛠️ Technology Stack

Technology Purpose
PHP 8.2+ Backend
OpenAI API AI responses
HTML5 Structure
CSS3 Interface design
JavaScript Chat functionality
PHP Sessions Conversation history

📋 Requirements

Before installation, make sure you have:

  • PHP 8.2 or newer
  • PHP cURL extension enabled
  • OpenAI API key
  • Web hosting with PHP support

🚀 Installation

1. Clone the repository

git clone https://github.com/Mojib-rsm/ai-agent.git

2. Open the project

cd php-ai-agent

3. Configure your API key

Set the following environment variables on your server:

OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4.1-mini

Never expose your API key in frontend JavaScript or commit it to GitHub.

4. Start the local server

php -S localhost:8000

5. Open in your browser

http://localhost:8000

Your AI Agent is ready!

⚙️ Configuration

You can customize the AI model through the environment variable:

OPENAI_MODEL=gpt-4.1-mini

The default assistant instruction is:

You are a helpful, accurate AI assistant.
Respond in the language used by the user.

You can customize this instruction inside index.php.

📂 Project Structure

php-ai-agent/
│
├── index.php
├── README.md
├── LICENSE
└── .gitignore

🔒 Security

  • Keep your OpenAI API key private.
  • Use server-side environment variables.
  • Add authentication before public deployment.
  • Implement rate limiting to prevent API abuse.
  • Add CSRF protection for production environments.
  • Monitor API usage and costs.

🔍 SEO Keywords

PHP AI Agent, PHP AI Chatbot, OpenAI PHP Integration, PHP Chatbot Source Code, AI Assistant PHP, OpenAI API Chatbot, Lightweight AI Chatbot, PHP Artificial Intelligence.

🗺️ Roadmap

  • OpenAI API integration
  • Responsive chat interface
  • Session-based conversation memory
  • New chat functionality
  • User authentication
  • MySQL conversation storage
  • Admin dashboard
  • File upload and document analysis
  • Web search integration
  • AI tool calling
  • Multiple AI models

🤝 Contributing

Contributions, suggestions, and improvements are welcome!

  1. Fork this repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

📄 License

This project is intended to use the MIT License. Add a LICENSE file before publishing under that license.

👨‍💻 Author

Mojib Rsm


⭐ If you find this project useful, consider giving it a star!

Built with ❤️ using PHP and OpenAI API.

About

A lightweight PHP AI chatbot powered by OpenAI API with conversation memory, responsive UI, and easy deployment.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages