[Multimodal, Image Generation, Consecutive Tool Use] M365 Native: Turning Microsoft 365 Copilot into an OpenAI-Compatible API

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:

http://127.0.0.1:4141

Open this address in your browser:

http://127.0.0.1:4141/

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 :star:

27 Likes

Great stuff, thanks for sharing! The key thing is that it even supports tool usage—that’s really impressive.

1 Like

Give it a try—does it incorporate the previous reverse engineering results from the experts?

Yes :ac01:

Awesome, I’ll download it and give it a try to see if it’s the same as calling the API.

Awesome, I’ll give it a try when I get the chance.

1 Like

Wow, I definitely have to try this out.
By the way, do you support calling GPT-5.6?

This is great :+1:t2:

Not sure how well it will work.

Support! There was a guy before who made closed-source software and even wanted to sell it, haha.

This is awesome, definitely deserves a like :+1:

Haha, at least now it supports consecutive tool calls :ac01:

Strong

Supported :xhj007:

Has anyone succeeded?

Just give it a try yourself, it doesn’t cost you anything anyway :ac01:

Impressive! Account login is convenient and the interface is clean! It can read local projects without issues!
The generated results are a bit different from calling the API directly—I’m not sure if it’s due to the prompts.
Web search is off by default.

:xhj17: My computer’s specs can’t keep up

The requirements aren’t that high—it’s totally sufficient for personal use. :ac01:

Thanks for your feedback! We’re working on improvements, and you’re welcome to submit issues or PRs. :xhj15: