M365 Native is a self-hosted Microsoft 365 Copilot API gateway. It connects ChatHub via Microsoft account authorization and provides OpenAI and Anthropic compatible interfaces, making it easy to use Microsoft 365 Copilot in AI clients, IDEs, and Agent tools.
Project repository:
Feature Overview
| Feature | Description |
|---|---|
| Microsoft 365 Copilot Integration | Connects to Copilot service using Microsoft account authorization |
| OpenAI Compatible Interface | Supports /v1/models, /v1/chat/completions, /v1/responses |
| Anthropic Compatible Interface | Compatible with clients using the Claude API format |
| Multi-model Support | Supports GPT, Claude, and reasoning model endpoints |
| Streaming Responses | Supports SSE streaming output for real-time content generation |
| Tool Invocation | Supports Function Calling, Tool Calling, and Agent scenarios |
| Multi-account Pool | Add and manage multiple Microsoft accounts |
| Token Refresh | WebUI allows immediate refresh of account tokens |
| API Key Management | Create, view, and revoke access keys |
| Web Admin Portal | Manage accounts, keys, settings, and operation logs |
| Debug Logs | Record request IDs, response status, duration, and upstream errors |
| Docker Deployment | Quickly launch via Docker Compose |
| Self-hosting | Data and account credentials are stored on your own server |
Docker Compose Deployment
1. Clone the Project
git clone https://github.com/uefi2333/m365-native.git
cd m365-native
2. Start the Service
docker compose up -d
Check status:
docker compose ps
View real-time logs:
docker compose logs -f m365-native
By default, the service listens on:
Open this address in your browser:
Default Admin Password
For your first WebUI login use:
- Default password:
admin123
After logging in, you will be prompted to change the admin password. Please change it immediately and do not continue using the default password.
When you first enter the WebUI, follow the prompts to complete admin login and Microsoft account authorization.
3. Stop the Service
docker compose down
Rebuild after updating the project:
docker compose up -d --build
Building With Docker Manually
If you do not use the pre-built image, you can also build directly:
docker build -t m365-native:latest .
Start the container:
docker run -d \
--name m365-native \
-p 127.0.0.1:4141:4141 \
-e M365_LISTEN=0.0.0.0:4141 \
-v m365-native-data:/root/.config/m365-native \
m365-native:latest
View logs:
docker logs -f m365-native
API Usage
View Models
curl http://127.0.0.1:4141/v1/models \
-H "Authorization: Bearer m365_yourAPIKey"
Chat Completions
curl http://127.0.0.1:4141/v1/chat/completions \
-H "Authorization: Bearer m365_yourAPIKey" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "Hello, please introduce yourself."
}
],
"stream": true
}'
Responses API
curl http://127.0.0.1:4141/v1/responses \
-H "Authorization: Bearer m365_yourAPIKey" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet",
"input": [
{
"role": "user",
"content": "Hello"
}
],
"stream": false
}'
WebUI Management
Once inside the WebUI, you can:
- Add Microsoft accounts;
- Manage the account pool;
- Instantly refresh account tokens;
- View account status and expiration times;
- Create and revoke API Keys;
- View request debug logs;
- Edit service configurations;
- Check service health.
Reverse Proxy and Public Deployment
If you need to access the service from the Internet, it is recommended to set up HTTPS and access control in front of the service, for example via:
- Cloudflare Tunnel;
- Nginx;
- Caddy;
- Traefik;
- Other HTTPS reverse proxies.
By default, Docker is set to bind to localhost:
ports:
- "127.0.0.1:4141:4141"
To allow access from other devices in the same LAN, change to:
ports:
- "4141:4141"
If deploying publicly, always set up HTTPS, an admin password, and API Keys to avoid exposing your account credentials and the API to unauthorized users.
Project Highlights
M365 Native is suitable for these scenarios:
- Integrating Microsoft 365 Copilot into third-party AI clients
- Providing a unified interface for IDEs or code assistants
- Building Copilot-based Agents
- Self-hosting a personal AI gateway on your server
- Quickly deploying your own Copilot API service using Docker
If you find this project helpful, feel free to star my repository ![]()