🤖 Copilot API
🚀 A powerful, unofficial Python API wrapper for Microsoft Copilot with CLI support
Installation • Features • Quick Start • CLI Usage • Examples • Contributing • Support
⭐ Stargazers
📦 Installation
# Using pip
pip install copilot-api
# From source
git clone https://github.com/OE-LUCIFER/copilot-api.git
cd copilot-api
pip install -e .
🎯 Key Features
- 🤖 Microsoft Copilot Integration - Direct access to Microsoft Copilot's capabilities
- 🔄 Streaming Support - Real-time response streaming for better interactivity
- 🛡️ Robust Error Handling - Comprehensive exception handling with custom error types
- 🔌 Flexible Configuration - Support for proxies, timeouts, and custom settings
- 🎨 Rich CLI Interface - Interactive terminal experience with syntax highlighting
- 📦 Lightweight & Fast - Minimal dependencies with efficient implementation
✨ Features
Core Features
- 🔄 Stream Chat Completions - Real-time streaming responses
- 💬 Conversation Management - Maintain context across messages
- 🔒 Proxy Support - Configure custom proxy settings
- ⚙️ Customizable - Flexible timeout and configuration options
CLI Features
- 🎨 Rich Text Interface - Beautiful terminal UI with syntax highlighting
- 📝 Interactive Chat - Full-featured chat interface in your terminal
- 💾 Session Management - Save and load conversation sessions
- 🎯 Multiple Commands - Dedicated commands for different functionalities
- 🔍 Help System - Built-in help and documentation
Developer Features
- 🛠️ Type Hints - Full type annotation support
- 📚 Rich Documentation - Comprehensive API documentation
- 🧪 Exception Handling - Detailed error messages and handling
- 🔌 Extensible - Easy to extend and customize
- 🎮 Multiple Interfaces - Use as library or CLI tool
🔧 Technical Details
Core Components
copilot.py- Main Copilot client implementationcli.py- Command-line interface implementationexceptions.py- Custom exception definitionsutils.py- Helper functions and utilities
Error Handling
The library includes custom exceptions for better error management:
from copilot_api.exceptions import CopilotError, AuthenticationError, APIError
try:
response = copilot.create_completion(messages=messages)
except AuthenticationError:
print("Authentication failed. Please check your credentials.")
except APIError as e:
print(f"API error occurred: {e}")
🚀 Quick Start
Python Library Usage
from copilot_api import Copilot
# Initialize Copilot
copilot = Copilot()
# Basic chat example
messages = [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "Hello!"}
]
# Stream responses
for response in copilot.create_completion(
model="Copilot",
messages=messages,
stream=True
):
if isinstance(response, str):
print(response, end='', flush=True)
🖥️ CLI Usage
Interactive Chat
# Start interactive chat
copilot-cli
# Start chat with specific model
copilot-cli --model Copilot
# Save conversation
copilot-cli --save chat_history.json
# Load previous conversation
copilot-cli --load chat_history.json
Alternative Usage
# Using Python module directly
python -m copilot_api.cli chat
# Or using the main command
copilot chat
CLI Commands
/help- Show help message/clear- Clear current conversation/save <filename>- Save conversation/load <filename>- Load conversation/exit- Exit the CLI
📚 Examples
💬 Managing Conversations
from copilot_api import save_conversation, load_conversation
# Save conversation
save_conversation("chat_history.json", messages)
# Load conversation
messages = load_conversation("chat_history.json")
🛠️ Advanced Usage
Proxy Configuration
copilot = Copilot(
proxy="http://your-proxy-server:port"
)
Custom Timeout Settings
copilot = Copilot(
timeout=30 # seconds
)
Advanced Configuration
from copilot_api import Copilot
# Initialize with custom configuration
copilot = Copilot(
timeout=30,
proxy="http://proxy:port",
max_retries=3,
verify_ssl=True
)
# Custom headers and parameters
response = copilot.create_completion(
messages=[{"role": "user", "content": "Hello!"}],
stream=True,
temperature=0.7,
max_tokens=150
)
CLI Features
The CLI tool (copilot-cli) supports various commands and options:
# Start with custom configuration
copilot-cli --timeout 30 --no-stream
# Export conversation
copilot-cli --export chat.json
# Import and continue conversation
copilot-cli --import chat.json
Available CLI commands:
/system <message>- Set system message/model <name>- Change model/retry- Retry last message/tokens- Show token count/version- Show version info
🔍 Debugging
Enable debug mode for detailed logging:
import logging
logging.basicConfig(level=logging.DEBUG)
copilot = Copilot(debug=True)
🧪 Testing
Run the test suite:
# Install test dependencies
pip install -e ".[test]"
# Run tests with coverage
pytest --cov=copilot_api tests/
📋 Requirements
- Python 3.7+
- Core Dependencies:
requests>=2.25.0websockets>=10.0aiohttp>=3.8.0python-dotenv>=0.19.0tls-client>=0.2.0beautifulsoup4>=4.9.3
- CLI Dependencies:
click>=8.0.0rich>=10.0.0prompt-toolkit>=3.0.0
🤝 Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/OE-LUCIFER/copilot-api.git
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
📝 License
This project is licensed under the HelpingAI License - see the LICENSE file for details.
The HelpingAI License is a proprietary license that grants specific rights while protecting HelpingAI's intellectual property. Please read the license carefully before using this software.
🌟 Support
- Star this repository
- Follow @OEvortex on YouTube
- Report issues on our Issue Tracker
- Consider sponsoring the project
📊 Project Stats
📈 Star History
Metadata
Release files for copilot-api 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| copilot_api-1.0.0.tar.gz | 18.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| copilot_api-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.5 kB
Release files / copilot_api-1.0.0.tar.gz
| Download URL | copilot_api-1.0.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8838366c5101240922a7bb17a40e8912944d41cbe9733830744b32e5d93d2bb6
|
|
BLAKE2b-256 checksum How to use checksums |
d8bba20b013ed3d5fba5ef067d07fa9a9b6cc8eb8fbf88c7d648d7592b63bf40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / copilot_api-1.0.0-py3-none-any.whl
| Download URL | copilot_api-1.0.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bff850f6b8ce4933cee4867f3316e4f79800c12aec933311782870e08846334b
|
|
BLAKE2b-256 checksum How to use checksums |
a2b2f8ffe5140d515de4c83563912b9fdc37aca4a913f7ba1d489d52211cd3f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|