Status: [LIVE] Endpoints found: https://api.star-history.com/svg?repos=kuchris/m365-copilot-openai-proxy&type=Date)](https://www.star-history.com/#kuchris/m365-copilot-openai-proxy Source: https://github.com/kuchris/m365-copilot-openai-proxy # Microsoft 365 Copilot OpenAI Proxy Use Microsoft 365 Copilot through OpenAI-compatible clients, local scripts, and coding tools. This project runs a local FastAPI proxy that talks to the same `substrate.office.com` WebSocket API used by the M365 Copilot web UI, then exposes it as OpenAI-style HTTP endpoints. No Azure app registration. No admin consent. Sign in with your normal M365 Copilot browser session. ## Why Use This - Use M365 Copilot from OpenAI-compatible clients - Works with your existing signed-in Copilot web session - Runs locally on `127.0.0.1` by default - Auto-captures and refreshes the short-lived browser token - Supports persistent Copilot sessions across turns - Supports OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages style requests ## Quick Start ```powershell uv sync uv run copilot-openai-proxy serve ``` The server starts at: ```text http://127.0.0.1:8000 ``` On first run, the proxy opens a dedicated Edge window. Sign in to M365 Copilot there once. The proxy will capture the required Substrate token and write it to `.env`. The dedicated Edge profile is stored at: ```text %USERPROFILE%\.m365-copilot-openai-proxy\edge-profile ``` If startup says it is waiting for a token, click the Copilot message box and type one character. You do not need to send the message. ## Test It ```powershell $body = @{ model = "m365-copilot" messages = @( @{ role = "user"; content = "Say hello in one short sentence." } ) } | ConvertTo-Json -Depth 10 $r = Invoke-RestMethod ` -Method Post ` -Uri "http://127.0.0.1:8000/v1/chat/completions" ` -ContentType "application/json" ` -Body $body $r.choices[0].message.content ``` ## Connect A Client Use these settings for any OpenAI-compatible client: | Setting | Value | |---|---| | Base URL | `http://127.0.0.1:8000/v1` | | API Key | `dummy` | | Model | `m365-copilot` | | Persistent model | `m365-copilot:persist` | ### OpenCode ```powershell $env:OPENAI_BASE_URL = "http://127