explaingit

andrewyng/aisuite

13,767PythonAudience · developerComplexity · 2/5Setup · easy

TLDR

aisuite is a lightweight Python library that wraps OpenAI, Anthropic, Google, Mistral, and a dozen other AI providers behind one consistent interface so you can switch models without rewriting code.

Mindmap

mindmap
  root((aisuite))
    What it does
      Unified AI interface
      Tool calling
      MCP support
    Providers
      OpenAI
      Anthropic
      Google
      Mistral
    Use Cases
      Model comparison
      Agent building
      Switch providers
    Audience
      Developers
      AI builders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Write one AI chat function and swap between GPT-4o, Claude, and Gemini by changing a single model string.

USE CASE 2

Add tool calling to an AI app where models run your Python functions and continue the conversation with the results.

USE CASE 3

Connect an AI agent to MCP-compatible tools without writing protocol boilerplate.

USE CASE 4

Test the same prompt across multiple AI providers side by side to compare output quality.

Tech stack

Python

Getting it running

Difficulty · easy Time to first run · 5min

Requires API keys for each provider you want to use, set them as environment variables before running.

In plain English

aisuite is a small Python library that lets you write code once and use it with many different AI model providers, such as OpenAI, Anthropic, Google, Mistral, Cohere, Hugging Face, and others. Each of those providers has its own SDK, its own way of setting up API keys, and its own parameter names. aisuite wraps all of them behind one consistent interface so you do not have to rewrite your code when switching between models. The interface is designed to feel like OpenAI's API, which many developers already know. To pick a model you write the provider name, a colon, and the model name, for example openai:gpt-4o or anthropic:claude-3-5-sonnet. You store API keys as environment variables or pass them to the client directly. From there you send a list of messages and get back a response in a standardized format, regardless of which provider is underneath. The library also handles tool calling, which is where an AI model can request that your program run a function and then continue the conversation with the result. You can pass real Python functions rather than writing out a JSON description of each one, and aisuite generates the necessary schema automatically. Setting a max_turns parameter lets the library manage the back-and-forth loop between the model and your tools without you having to write that loop yourself. It also supports connecting to tools that follow the MCP standard without extra boilerplate. The README describes it as lightweight rather than a full agent framework, though it does include simple building blocks for standalone agents. You can install just the base library, add only the providers you need, or install everything at once. Adding support for a new provider means writing one file, which makes the project easy to extend. The examples folder contains Jupyter notebooks for trying out the interface. The project was created by Andrew Ng, a well-known figure in AI education.

Copy-paste prompts

Prompt 1
Show me how to set up aisuite with both openai:gpt-4o and anthropic:claude-3-5-sonnet, send the same message to both, and compare the responses in Python.
Prompt 2
I want to use aisuite's tool calling feature. Write me a Python example where the model calls a real Python function that looks up current weather data.
Prompt 3
How do I add a new AI provider to aisuite? Show me the interface a provider file must implement and give me a minimal example.
Prompt 4
Set up aisuite to connect to an MCP server and let a model use its tools without writing extra boilerplate code.
Prompt 5
Write an aisuite script that iterates through five different models, sends the same coding question to each, and prints each response labeled with its model name.
Open on GitHub → Explain another repo

← andrewyng on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.