Simple, unified interface to multiple Generative AI providers — Andrew Ng(吴恩达)出品

14.6k stars | Python | MIT | 2024-06

三层架构

┌───────────────────────────────────────────────┐
│                 OpenCoworker                  │   桌面 AI 工作伴侣(demo 参考实现)
├───────────────────────────────────────────────┤
│        Agents API  ·  Toolkits  ·  MCP        │   构建 Agent,跨 LLM 工具调用
├───────────────────────────────────────────────┤
│             Chat Completions API              │   统一 OpenAI 风格接口
├────────┬───────────┬────────┬────────┬────────┤
│ OpenAI │ Anthropic │ Google │ Ollama │ Others │
└────────┴───────────┴────────┴────────┴────────┘

核心功能

Chat Completions API — 跨 provider 统一接口

模型名格式:<provider>:<model-name>,切换 provider 只改一个字符串:

import aisuite as ai
client = ai.Client()
 
models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20240620"]
for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Hello"}],
    )

支持 OpenAI、Anthropic、Google、Mistral、Hugging Face、AWS、Cohere、Ollama、OpenRouter 等。

Agents API — 工具调用一行搞定

直接把 Python 函数作为工具传入,aisuite 自动生成 schema、执行调用、把结果喂回模型:

def get_weather(location: str) -> str:
    """Get weather for a location."""
    return "Sunny"
 
response = client.chat.completions.create(
    model="openai:gpt-4o",
    messages=messages,
    tools=[get_weather],
    max_turns=5,
)

内置 Toolkits:files(文件读写)、git、shell,以及任意 MCP Server。

OpenCoworker — 桌面 AI 工作伴侣

基于 aisuite 构建的桌面 AI Agent 参考实现,支持:

  • 深度研究 + 文件读写(PDF/报告/电子表格)
  • 收发消息(Slack、Email)
  • 定时自动化(每日新闻摘要等)
  • BYOK:OpenAI/Anthropic/Google API key 或本地 Ollama

安装

pip install aisuite               # 基础包
pip install 'aisuite[anthropic]'  # 包含特定 provider SDK
pip install 'aisuite[all]'        # 所有 provider SDK

为什么值得关注

  • Andrew Ng 出品:可信度高,设计理念清晰
  • 极轻量:不绑定任何 provider,纯统一接口层
  • Agent 开发起点:Agents API + Toolkits + MCP 三合一,适合快速搭建跨 LLM 的 Agent
  • OpenCoworker 是完整参考实现:展示了如何用 aisuite 构建生产级 Agent 应用

适用场景

  • 需要同时测试多个 LLM(benchmark 对比)
  • 构建不绑定单一 provider 的 Agent 应用
  • Python 生态中快速接入工具调用能力

局限性

  • Python 专属,无其他语言 SDK
  • 不是 LangChain 级别的完整框架,更像薄层封装
  • Agents API 较新,生态相比 LangChain/LlamaIndex 还小

关联页面