A Proxy for Microsoft 365 Copilot in OpenAI-Compatible Tools
A local FastAPI proxy makes Microsoft 365 Copilot available as a model provider for any AI agent or CLI tool that already supports the OpenAI chat completions format.
A local FastAPI proxy makes Microsoft 365 Copilot available as a model provider for any AI agent or CLI tool that already supports the OpenAI chat completions format. Hermes Agent, OpenCode, and OpenClaw work with it natively.
How it runs
The proxy is a FastAPI service. It starts on localhost:8081 and exposes two endpoints: /v1/chat/completions and /v1/models. Requests come in through those endpoints. Replies go back through them as well.
On the back end, the proxy authenticates with Azure AD OAuth2, talks to Copilot through the Microsoft Graph API, and maps that response into the OpenAI format the tools expect.
Authentication
Two OAuth2 flows are supported. Device Code flow handles headless and SSH environments. PKCE Authorization Code flow handles browser-based use. Tokens sit on disk with background refresh.
Keeping conversations sane
The proxy holds Copilot conversation state in memory. Conversations rotate at 50 turns to keep the context window under control. If a conversation goes stale, the proxy recreates it. No manual intervention.
Streaming
The Graph Copilot API does not stream. The proxy fakes SSE streaming. The response arrives as one chunk with a proper finish signal. That keeps the OpenAI client happy without changing what is happening under the hood.
Configuration
Setup takes about one line in Hermes. A custom provider with a base_url pointing at the proxy is enough. No API key is needed. OAuth is handled by the proxy.
Why this matters
Microsoft 365 Copilot sits on top of organisational data: SharePoint, email, Teams transcripts. That is valuable context for an agent. But that data is locked behind the Graph API, which makes it hard to use from open-source tools.
This proxy removes that barrier. Developers do not need to rework each tool individually. The repo includes documentation for Azure AD app registration, proxy setup, and Hermes Agent configuration. Setup takes about 10 minutes.
Where this could go
I am keen for other developers to pick this up and push it further. Enterprise knowledge bases connected to autonomous coding agents is a space worth exploring. If you want to experiment with it, the repo is here: https://github.com/rusty4444/copilot-365-hermes-proxy
Thanks to the team at Nous Research for building the agent infrastructure that makes integrations like this possible.
Connect with me on LinkedIn.