aisuite Skill:一个 API 调用 OpenAI/Anthropic/Google/Ollama 等 10+ 家 LLM 提供商

一个 Python 库,通过统一 Chat Completions 接口让你用同一套代码切换 10+ 家 LLM 提供商(OpenAI、Anthropic、Google、Ollama、Mistral、HuggingFace 等),同时提供完整的 Agents API(工具调用、MCP 拓展、Tool Policies)。今天(2026-07-29)冲上 GitHub Trending,Star 数 15.7k,属于开发者工作流类 Skill 的爆款。

功能与原则

aisuite 将 LLM 集成拆成两层:

  • Chat Completions API:统一 OpenAI 风格接口,切换模型只需改一个字符串(如 "anthropic:claude-sonnet-4-6")。
  • Agents API:在统一接口之上叠加工具调用、多轮循环、MCP 服务器连接、Tool Policy 审批机制。

核心原则是零平台锁定:无论换哪家基座模型,上层代码几乎不用改。同时支持 Streaming、Async、Tool Calling 原生输出格式。

认可度

  • GitHub Star:截至 2026-07-29 约 15,776(1,662 forks)
  • 今日状态:GitHub Trending 上榜(2026-07-29)
  • 定位:开发者工具类 Skill,不是普通用户的 Prompt Skill,而是底层架构 Skill

链接

GitHub:https://github.com/andrewyng/aisuite

原作者

andrewyng(GitHub @andrewyng)——专注 AI 应用层基础设施,aisuite 是其代表作,另有一个桌面 AI coworker 产品 OpenWorker 也基于 aisuite 构建。

介绍

aisuite 是一个轻量级 Python 库,解决 LLM 应用开发中最常见的痛点:每个提供商有自己的 SDK、自己的参数命名、自己的认证方式,换一个模型要从头改一遍。

它提供两条核心能力:

Chat Completions 统一接口:支持 OpenAI、Anthropic、Google、Mistral、HuggingFace、AWS Bedrock、Cohere、Ollama、OpenRouter 等,只需换 <provider>:<model-name> 这个字符串,temperature、max_tokens、tools 等参数以统一格式传入,结果以标准 OpenAI-shape 返回。

Agents API:不只是对话,而是给模型真工具。传入任意 Python 函数,aisuite 自动生成 tool schema、执行调用、把结果喂回模型。支持多轮工具对话(max_turns 控制轮数)、内置 File/Git/Shell 工具箱(Toolkits),以及任意 MCP 服务器直连。配合 Tool Policy(RequireApprovalPolicy / allowlist / denylist)可实现工具调用审批流。

特点

  • 零成本换模型:同一段代码,改一个字符串从 GPT-4o 切到 Claude-3.5-Sonnet
  • 工具调用极简:Python 函数直接作为工具传入,无需手写 JSON Schema
  • MCP 原生支持:pip install ‘aisuite[mcp]’ 后,任何 MCP 服务器的工具直接注入 Agent
  • Streaming / Async 全支持:Streaming 输出与工具调用可并行(需手动工具循环)
  • Provider 拓展规范清晰:新增 Provider 只需实现一个轻量 adapter 类,遵守命名约定即可自动被发现和加载
  • Toolkits 开箱即用:File/Git/Shell 工具箱已内置,生产级 Agent 无需从零搭

使用方法

安装

pip install aisuite                        # 基础包
pip install 'aisuite[anthropic]'           # 加指定 provider
pip install 'aisuite[all]'                 # 全量 provider

基本调用(统一 Chat Completions):

import aisuite as ai
client = ai.Client()

models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20240620"]
messages = [
    {"role": "system", "content": "Respond in Pirate English."},
    {"role": "user", "content": "Tell me a joke."},
]

for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=messages,
        temperature=0.75
    )
    print(response.choices[0].message.content)

Agent 工具调用(Python 函数直接作工具):

import aisuite as ai
from aisuite import Agent, Runner

def will_it_rain(location: str, time_of_day: str) -> str:
    """Check if it will rain in a location at a given time today."""
    return "YES"

client = ai.Client()
response = client.chat.completions.create(
    model="openai:gpt-4o",
    messages=[{"role": "user", "content": "I live in San Francisco. Plan an outdoor picnic at 2pm."}],
    tools=[will_it_rain],
    max_turns=2
)
print(response.choices[0].message.content)

Agent + Toolkit(文件系统 + Git)

import aisuite as ai
from aisuite import Agent, Runner

agent = Agent(
    name="repo-helper",
    model="anthropic:claude-sonnet-4-6",
    instructions="You are a careful repo assistant. Use your tools to answer from the code.",
    tools=[*ai.toolkits.files(root="."), *ai.toolkits.git(root=".")],
)

result = Runner.run(agent, "What changed in the last commit? Summarize in 3 bullets.")
print(result.final_output)

使用场景与人群

  • 多模型评测场景:同一个 Prompt 在 GPT-4o / Claude-3.5-Sonnet / Gemini 之间快速对比输出质量
  • LLM 应用开发者:不想被单一 Provider 绑定,需要灵活切换或做冗余兜底的团队
  • AI Agent 框架搭建者:需要可靠的工具调用层和 MCP 接入能力
  • 企业内部 AI 平台:对接多家 LLM 服务商,需要统一抽象层降低集成复杂度

输入与输出案例

案例一:跨模型问答

输入:

model: "openai:gpt-4o" + "anthropic:claude-3-5-sonnet-20240620"
messages: [{"role": "user", "content": "解释什么是 RAG"}]

输出:
– GPT-4o:返回一段关于 Retrieval-Augmented Generation 的解释(约 150 字)
– Claude:返回另一版本解释,带有不同侧重点(如引用最新研究)
价值:同一 Prompt 横向对比两个模型输出,快速选型

案例二:带工具调用的多轮 Agent

输入:

model: "openai:gpt-4o"
user: "What changed in the last commit?"
tools: [*ai.toolkits.git(root=".")]  # 内置 Git Toolkit
max_turns: 3

输出:

- Agent 调用 git tool 获取 diff
- Agent 分析变更内容
- Agent 总结为 3 条 bullet point 输出

整个过程无手动干预,模型根据 Tool 返回结果自主决定下一步调用。


GitHub: https://github.com/andrewyng/aisuite

评论区

0 条评论

登录后可评论。

Skill超级捕获手 19 阅读