HEXUXIU GitHub avatar

M365-Copilot2API

HEXUXIU

M365 Copilot2API is a gateway that converts Microsoft 365 Copilot into OpenAI / Anthropic compatible APIs, supporting streaming, tool calls, MCP protocol, and multiple models.

Stars

88

7-day growth

No data

Forks

21

Open issues

3

License

MIT

Last updated

2026-07-21

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It bridges proprietary M365 Copilot with open API standards, enabling developers to use powerful Copilot models via familiar OpenAI or Anthropic interfaces, and includes advanced features like MCP protocol and multi-account management.

Who it is for

  • Developers integrating M365 Copilot into existing AI workflows
  • Administrators managing multiple Copilot accounts and API keys
  • Users who want to access Copilot models through standard chat completion APIs
  • Builders of custom AI applications needing gateway functionality

Use cases

  • Use as a drop-in backend for any OpenAI-compatible client (e.g., ChatGPT apps)
  • Build chatbots and tools that leverage M365 Copilot reasoning models
  • Integrate Copilot into MCP-aware applications for dynamic tool execution
  • Create a controlled API layer with account pooling and proxy rotation

Strengths

  • OpenAI and Anthropic API compatibility with streaming and tool calling
  • Supports multiple Copilot models including reasoning variants (gpt-5.5-reasoning, gpt-5.6-sol)
  • Includes MCP protocol endpoints for model context protocol
  • Provides web admin console, API key management, and proxy pool for production use

Considerations

  • Requires valid M365 Copilot subscription – not a standalone AI service
  • Models and features are limited to those exposed by the Copilot backend
  • Security depends on proper configuration (default binds to localhost, admin password change recommended)

README quick start

M365 Copilot2API

M365 Copilot ChatHub 网关 将 Microsoft 365 Copilot 转换为 OpenAI / Anthropic 兼容 API


📋 功能特性

功能状态
✅ OpenAI 兼容 /v1/chat/completions支持流式、工具调用
✅ OpenAI Responses /v1/responses兼容
✅ Anthropic 兼容 /v1/messages兼容
✅ 流式输出 (SSE)实时逐字输出
✅ 推理模型gpt-5.5-reasoning、gpt-5.6-sol 等
✅ 联网搜索claude-sonnet 内置 web_fetch
✅ MCP 协议/v1/mcp/sse + /v1/mcp/message + /v1/mcp/tools
✅ 视觉识别支持 base64 图片输入
✅ 多账号管理PKCE OAuth 授权
✅ API Key 管理控制台创建/撤销
✅ 代理池轮换、失败冷却
✅ Web 管理控制台账号、设置、日志

🚀 快速开始

源码编译

git clone https://github.com/HEXUXIU/M365-Copilot2API.git
cd M365-Copilot2API
# 配置管理员密码(可选,默认 admin123)
export M365_ADMIN_PASSWORD=your_password
go run ./cmd/server

默认地址 http://127.0.0.1:4141,打开浏览器完成管理员设置和登录。

Docker 部署

docker compose build
docker compose up -d

🔑 使用示例

# 基础聊天
curl http://127.0.0.1:4141/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "你好"}]
  }'

# 流式输出
curl http://127.0.0.1:4141/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5-reasoning",
    "messages": [{"role": "user", "content": "1+1=?"}],
    "stream": true
  }'

# 联网搜索(claude-sonnet 内置)
curl http://127.0.0.1:4141/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet",
    "messages": [{"role": "user", "content": "北京今天天气?"}]
  }'

🤖 可用模型

模型推荐用途速度
gpt-5.5日常对话⚡ ~5s
gpt-5.2最轻量快速⚡ ~5s
claude-sonnet联网搜索、实时信息⚡ ~5-6s
gpt-5.6-sol复杂推理(默认高推理)⏳ ~7s
gpt-5.5-reasoning数学/逻辑推理⏳ ~9s

🧩 MCP 协议

网关内置 MCP (Model Context Protocol) 服务器:

端点说明
GET /v1/mcp/sseSSE 连接
POST /v1/mcp/messageJSON-RPC 消息
GET /v1/mcp/tools工具列表
tools/list发现工具
tools/call调用工具

🛠 技术栈

  • 语言: Go 1.22+
  • 协议: SignalR / WebSocket / SSE / MCP
  • 前端: 单页 HTML + Inter 字体 + Lucide 图标
  • 部署: Docker / 裸机

📄 配置

变量默认值说明
M365_LISTEN`

Description

Access M365 Copilot via CLI & OpenAI-compatible API

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482