Skip to content

Guide · Open source

How to use aisuite: install, switch LLM providers and add tools

Updated · written with AI from the project's own documentation and checked against our catalogue data

aisuite is an open-source Python library from andrewyng that lets you call language models from several providers, such as OpenAI, Anthropic and Google, through one common format. This guide is for Python developers who want to compare or switch providers without rewriting code. By the end you will know how to install it, make a chat call, stream responses and give a model plain Python functions as tools.

aisuiteandrewyng/aisuite · ★ 16.4k · MIT

Quick start

  1. 1Install the package. Run pip install aisuite, or pip install 'aisuite[all]' to include every provider SDK.
  2. 2Get API keys. Obtain keys for the providers you plan to call, following the Chat Completions quickstart in the repository.
  3. 3Create a client. Import aisuite as ai and create a client with ai.Client().
  4. 4Pick a model. Choose a model using the provider:model-name format, such as openai:gpt-4o.
  5. 5Send messages. Call client.chat.completions.create with your model and messages, and print the reply.
  6. 6Add tools if needed. Pass plain Python functions with docstrings to tools and set max_turns to let the model call them.

What aisuite is and who it is for

aisuite is a lightweight Python library for building with LLMs. It has two layers: a Chat Completions API that works the same way across providers, and an Agents API with tools and toolkits built on top of it.

It is a code library, so you need to write Python to use it. If you only want a ready-made chat app, the README points to the separate OpenWorker desktop app, which is developed in its own repository.

  • Good fit: Python developers comparing or switching between LLM providers, and developers building simple tool-using agents with plain Python functions.
  • Not a fit: non-programmers, or anyone who only wants a chat interface.

Install aisuite with pip

Install the base package, or include the SDKs of the providers you plan to use. The base package does not install provider SDKs.

You will also need API keys for the providers you call. The Chat Completions quickstart in the repository covers key setup and your first calls.

pip install aisuite # base package, no provider SDKs pip install 'aisuite[anthropic]' # with a specific provider's SDK pip install 'aisuite[all]' # with all provider SDKs

Make your first call with a provider:model string

Model names use the format <provider>:<model-name>. aisuite routes the call to the right provider with the right parameters, so switching providers means changing one string.

The example below sends the same messages to two models and prints each reply. Parameters such as temperature are passed in a provider-agnostic way.

  • Change the model string, for example from openai:gpt-4o to anthropic:claude-3-5-sonnet-20240620, to switch provider.
  • Use the same messages list for every model you want to compare.
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)

Stream responses

Pass stream=True to receive an iterator of OpenAI-shaped chunks. The README lists OpenAI, Anthropic, Ollama and OpenAI-compatible endpoints as supporting streaming, and the same loop works across them.

The async variant is await client.chat.completions.acreate(..., stream=True), iterated with async for. Streaming is manual tool calling and cannot be combined with max_turns.

for chunk in client.chat.completions.create(model=model, messages=messages, stream=True): print(chunk.choices[0].delta.content or "", end="", flush=True)

Give a model Python functions as tools

aisuite turns tool calling into a short step. You pass plain Python functions, and aisuite generates the schemas, executes the calls and feeds the results back to the model. Use a docstring with Args so the model knows what each parameter means.

With max_turns set, aisuite repeats the loop until the conversation completes. response.choices[0].intermediate_messages holds the full tool interaction history. If you prefer manual control, omit max_turns and pass OpenAI-format JSON tool specs; aisuite then returns the tool-call requests and you run the loop yourself. The repository's examples/tool_calling_abstraction.ipynb shows both styles.

def will_it_rain(location: str, time_of_day: str): """Check if it will rain in a location at a given time today. Args: location (str): Name of the city time_of_day (str): Time of the day in HH:MM format. """ return "YES" client = ai.Client() response = client.chat.completions.create( model="openai:gpt-4o", messages=[{ "role": "user", "content": "I live in San Francisco. Can you check for weather " "and plan an outdoor picnic for me at 2pm?" }], tools=[will_it_rain], max_turns=2 ) print(response.choices[0].message.content)

Use the Agents API and MCP tools

For longer structured work, the Agents API lets you declare an agent once, run it with a Runner, and attach toolkits for files, git and shell. The README also describes tool policies, state stores (in-memory, file or Postgres) and artifact and tracing support.

aisuite supports the Model Context Protocol, so an MCP server's tools can be handed to a model with little setup. Installing the MCP extra uses pip install 'aisuite[mcp]'. For reusable connections, security filters and tool prefixing, the README recommends the explicit MCPClient.

  • Tool policies: RequireApprovalPolicy, allow/deny lists, or your own callable.
  • State stores: persist and resume runs.
  • Toolkits: prebuilt, sandboxed tool families for files, git and shell.
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)

Add a new provider

New providers can be added by implementing a lightweight adapter. The system uses a naming convention for discovery, which the README describes in its provider table.

What people use it for

  • Comparing answers from OpenAI and Anthropic models on the same prompt by changing only the model string.
  • Building a simple agent that calls your own Python functions, such as a weather check, through tools.
  • Letting a model read and search files or run git commands using the files and git toolkits.
  • Connecting an MCP server's tools to a model with a single tools entry.

Frequently asked questions

Is aisuite free to use?

aisuite is released under the MIT licence, as stated in the repository. You still need your own API keys for the providers you call, and those providers may charge for usage.

How do I install aisuite?

Run pip install aisuite for the base package. Use pip install 'aisuite[all]' to include the SDKs for all supported providers, or install a single provider's extra such as 'aisuite[anthropic]'.

What do I need to run aisuite?

The README lists Python as the prerequisite. You also need API keys for any provider you want to call.

Which providers does aisuite support?

The README lists OpenAI, Anthropic, Google, Mistral, Hugging Face, AWS, Cohere, Ollama, OpenRouter, Requesty and more. Switching providers means changing the model string.

How does aisuite compare to LiteLLM or LangChain?

The repository names LiteLLM, LangChain and LlamaIndex as comparable projects but does not compare them in detail. aisuite is described as a lightweight library with a unified Chat Completions API and a simple Agents layer.

Can I use aisuite without writing code?

No. aisuite is a Python library, so you need to write Python. For a desktop app, the README points to OpenWorker, a separate project.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

aisuite suits Python developers who want one calling style across several LLM providers and simple tool use with plain functions. If you want a ready-made chat app, or a larger framework with many built-in integrations, look at OpenWorker or a project such as LangChain instead.

Install options & downloads