A professional REST API to interface with Ollama and local language models.
# Install dependencies
pip install -r requirements.txt
# Start the API
python app.py
The API will be available at:
- Local:
http://localhost:5000
- Local Network:
http://[YOUR_MACHINE_IP]:5000
GET /health
- API statusPOST /generate
- Text generationPOST /chat
- Chat conversationsGET /list
- List modelsPOST /pull
- Download modelsPOST /stop
- Stop modelsGET /ps
- Process status
Create a .env
file in the project root to customize the configuration:
# Server Configuration
API_HOST=0.0.0.0
API_PORT=5000
API_DEBUG=True
# Ollama Configuration
OLLAMA_HOST=localhost
OLLAMA_PORT=11434
# Security Configuration (optional)
API_KEY=your_secret_api_key
ALLOWED_IPS=192.168.1.100,192.168.1.101
# Logging Configuration
LOG_LEVEL=INFO
LOG_FILE=logs/api.log
- Complete Documentation - Detailed guide
- Test Examples - Test scripts and examples
- Utility Scripts - Startup and configuration scripts
IA_API/
├── src/ # Source code
│ ├── api.py # Main API
│ ├── utils.py # Utilities
│ └── __init__.py # Package init
├── config/ # Configuration
│ └── settings.py # Settings
├── tests/ # Tests
│ ├── test_api.py # Local tests
│ └── test_remote_api.py # Network tests
├── scripts/ # Scripts
│ └── start_api.bat # Windows startup
├── docs/ # Documentation
│ └── README.md # Detailed docs
├── app.py # Entry point
├── requirements.txt # Dependencies
└── .env.example # Configuration example
The API supports:
- API Key Authentication (optional)
- IP Filtering (optional)
- Configurable CORS
- Input Validation
- Rate Limiting (configurable)
- Python 3.7+
- Ollama installed and running
- Ollama models downloaded (
ollama pull <model_name>
)
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is released under the MIT license. See the LICENSE file for details.
Developed with ❤️ for the Ollama community