Sharing a gateway that turns Microsoft M365 Copilot into an OpenAI / Claude-compatible API: Copilot Bridge (each account has its own dedicated IP proxy – really nice!)

▎A Few Words to Start

This project isn’t just something I came up with on my own — it’s built standing on the shoulders of multiple open-source contributors, so I want to start with proper thanks:
:folded_hands: @uefi2333 — Author of m365-native, which is the upstream project. The entire framework for the ChatHub (SignalR WebSocket) gateway, as well as the approach to authentication and protocol conversion, all came from there. I did a big rebrand, added features, and swapped out the frontend on top of it.
:folded_hands: @tanmoumou252 — The guy in the group who shared the token estimation method. Microsoft’s ChatHub doesn’t return a usage field at all, but his “structured + whitespace-heuristic” algorithm finally made token counting more reliable instead of just guessing.
:folded_hands: @HEXUXIU — Author of M365-Copilot2API. Many implementation details only worked out after precisely referencing that repo.
Special thanks to all of them — my code uses their work surgically, not random merges, and all sources are credited in the repo.
I also referenced a few GitHub projects but honestly can’t remember or find the originals anymore — sending thanks here as well.
────────────────────────────────────────

▎What’s This Project For?

In short: Copilot Bridge turns Microsoft’s M365 Copilot ChatHub into an OpenAI/Anthropic-compatible API. All your OpenAI SDKs, Claude SDKs, various agent frameworks, or even curl, can call M365 Copilot directly, with no need to deal with Microsoft’s private protocol.
Supports /v1/chat/completions, /v1/responses, /v1/messages — streaming, multimodal, tool calling — all included. Multiple account pool rotation, rate-limiting with self-healing, API key expiration, token statistics, these are all supported.
But today, I want to highlight one feature I’m most excited about: you can set a separate proxy IP for each account.
────────────────────────────────────────

▎:star: Key Feature: A Separate Outbound IP for Each Account
Anyone who’s run an account pool knows the biggest risk: seeing all your accounts use the same outbound IP and have Microsoft instantly flag them and apply risk controls. Copilot Bridge solves this by assigning proxies at the account level — not globally.
In other words:
· Got 10 M365 accounts? You can set a different outbound proxy for each one.
· Each account’s ChatHub WebSocket connection, plus its token refresh, all pass through its own proxy.
· Leave blank = direct connection. You can mix and match, with some accounts using proxies, some connecting directly.
Multiple accounts + multiple IPs means a much lower chance of association and risk control. That’s why I think this feature really deserves special mention.

▎How to Set Proxies (Leave Blank for Direct Connection)
In the “Proxy” input for each account, you can use any of the following formats:
[Format 1] Just host:port (defaults to SOCKS5)
1.2.3.4:1080
[Format 2] Standard SOCKS5
socks5://1.2.3.4:1080
[Format 3] SOCKS5 with username and password (standard three-part)
socks5://user:[email protected]:1080
[Format 4] SOCKS5 with username and password (non-standard four-part, used by some providers)
socks5://1.2.3.4:1080:user:pass
[Format 5] SOCKS5 + remote DNS (domain resolution by proxy)
socks5h://1.2.3.4:1080
[Format 6] SOCKS4 (can carry user:pass@)
socks4://1.2.3.4:1080
[Format 7] HTTP proxy (CONNECT tunnel)
http://1.2.3.4:8080
[Format 8] HTTP proxy with username and password
http://user:[email protected]:8080
[Format 9] HTTPS proxy (real TLS; only the proxy connection skips certificate verification, target site still verifies)
https://1.2.3.4:8443
(Note) The protocol matching logic is in internal/proxy/proxy.go: http(s)://, socks5/socks5h/socks4:// — all support both three-part ([user:pass@]host:port) and four-part (host:port:user:pass) formats. No scheme = SOCKS5 by default.

▎:warning: Two Pitfalls for New Users (I Stepped on Both!)

Pitfall 1: Many so-called “HTTPS proxies” are actually just HTTP CONNECT endpoints. For these, use http://, not https://, or they won’t connect. Use https:// only for those that do real TLS listening on the client port.
Pitfall 2: If your password contains @ or :, the standard three-part user:pass@host:port will break. Use the four-part host:port:user:pass instead (don’t use colons in user/pass).

▎How to Test Connection

Single account: Fill in the proxy, click “Test” — you’ll immediately see the outbound IP and latency (✓ for green, ✗ for red), showing if the proxy works and which IP is used.
Batch test: On the account list page there’s a “Batch Test Proxies” button (next to “Reset Stats”). Click to probe all proxies in parallel; results are shown inline for each line and a banner summary at the top (“Success N / Fail M”), so you can spot broken proxies at a glance.
Certificates: Only the “to proxy” connection skips cert verification (for expired/self-signed proxies—same as fingerprint browsers), but the MS/ipify TLS is still verified — so security’s not affected.
────────────────────────────────────────

▎Other Features Worth Mentioning (Details Skipped)

:glowing_star: API Key Expiry — You can set each access key as “permanent / expires in N days”; expires = instant 401; you can revert to permanent anytime, keys saved as hashes.
:glowing_star: Token Estimate — When MS doesn’t return usage, gives a reliable estimate (gpt- models use real tiktoken, others use community heuristics), with both overall and per-account stats, plus a “reset stats” button to zero all counts (stats are persisted in stats.json).
:glowing_star: Rate Limiting & Health — Account status displayed live, 429s trigger a 2-min cooldown and switch to a healthy account.
:glowing_star: Web Console — Account pool/add accounts (built-in PKCE OAuth), API access management, run logs, settings — five tabs ready-to-use out of the box.
────────────────────────────────────────

▎Project Link & Quick Start

GitHub: GitHub - shenping1200/m365-copilot-bridge: M365 Copilot ChatHub gateway — OpenAI-compatible API (Copilot Bridge) · GitHub
Start a Docker instance (defaults to 127.0.0.1:4141):
git clone GitHub - shenping1200/m365-copilot-bridge: M365 Copilot ChatHub gateway — OpenAI-compatible API (Copilot Bridge) · GitHub
cd m365-copilot-bridge
mkdir -p data secrets
printf ‘%s\n’ ‘replace with your own long random admin password’ > secrets/m365_admin_password
chmod 600 secrets/m365_admin_password
docker compose build && docker compose up -d
Open http://127.0.0.1:4141/ in your browser → log in → complete Microsoft authorization → create a key in “Access Config” → use the key to call /v1.

:warning: Compliance Notice: This project is an interoperability gateway, not a tool for bypassing authentication. Please only use it with Microsoft accounts and tenants you have the right to use. Default binding is to localhost; always enable TLS and access control before exposing it externally.
────────────────────────────────────────
Here are some screenshots to give you an idea of the project’s features:



That’s all. In short: if you want every M365 account to use a separate outbound IP for better risk dispersion, Copilot Bridge’s per-account proxy feature works out of the box — just fill in host:port and go. If you have questions, feel free to reply and discuss.

If you found this useful, please leave a star and a like — it’s much appreciated!

There’ll definitely be issues as you use it, so I’ll keep updating the project. Feel free to share your experience and feedback.

54 Likes

It seems like someone on the site has already set this up, and it supports Docker deployment, so we can switch to it later.

1 Like

Support

1 Like

Wait, what’s exactly is the token limit per account?

Its biggest weakness is that it speaks too slowly—the first character takes six or seven seconds.

1 Like

This thing can’t really be used as your main model, but it’s pretty good for automating tasks. It’s free, so what more can you ask for?

Unlimited

1 Like

Hey hey hey, this is way too much AI flavor :ac01:

The flavor is strong, no need to say more, right? :skull:

Also, wasn’t I the one who started the M365 reverse engineering? Why doesn’t anyone just compare the project creation dates, come on?!

Of course, the Go version does come from uefi2333’s m365-native — my later work was indeed based on his (I started with a Python version at first, but everyone complained about it). And there’s no way this project was done by just a few people, right?

We should thank every developer in the entire community who helped with troubleshooting issues, analyzing, discovering problems, giving feedback, and continuously optimizing and adjusting the project :xhj006:

3 Likes

You’re one of the contributors too. With such a long text, you expect me to type it all out manually? That’s exhausting.

I’ve seen too much; I can’t remember it all.

The author’s distinctive avatar reminds me of a certain friend who disappeared :xhj48:

They also posted about M365 before

2 Likes

hmmm, actually, there’s no need for so much detail. The specific details can go in the readme. Just briefly mention what was added.

3 Likes

You can just have the AI go take a look around the forum itself :xhj16:

4 Likes

All I can say is that m365 really brings together the strengths of all the Nler pros. :ac01:

1 Like

A lot of people are studying this project. You guys are really going all out with it, even though it’s free. Thanks for sharing.

1 Like

For a post like this, it’s only fair to like it before reading.

1 Like

He has so many great minds on board—support!

1 Like

After all, everyone in the community already knows what this thing does, so a brief introduction should be enough.

You can just say that it uses one account per IP to reduce the risk of triggering fraud controls.

If it’s that long, chances are not everyone will read it all :skull:

Another one—I’m getting overwhelmed by all the choices. We should make a consolidated one.

2 Likes

This IP proxy feature is great—being able to use multiple accounts is really awesome.

1 Like