


AISuite: Simplifying GenAI integration across multiple LLM providers
Generative AI (Gen AI) is reshaping industries with its potential for creativity, problem-solving, and automation. However, developers often face significant challenges when integrating large language models (LLMs) from different providers due to fragmented APIs and configurations. This lack of interoperability complicates workflows, extends development timelines, and hampers the creation of effective Gen AI applications.
To address this, Andrew Ng’s team has introduced AISuite, an open-source Python library that streamlines the integration of LLMs across providers like OpenAI, Anthropic, and Ollama. AISuite enables developers to switch between models with a simple “provider:model” string (e.g., openai:gpt-4o or anthropic:claude-3-5), eliminating the need for extensive code rewrites. By providing a unified interface, AISuite significantly reduces complexity, accelerates development, and opens new possibilities for building versatile Gen AI applications.
In this article, we will explore how AISuite works, its practical applications, and its effectiveness in addressing the challenges of working with diverse LLMs.
Getting Started
Table of contents
- What is AISuite
- Why is AISuite important
- Experimenting with AISuite
- Creating a Chat Completion
- Creating a generic function for querying
What is AISuite
AISuite is an open-source Python library developed by Andrew Ng’s team to simplify the integration and management of large language models (LLMs) from multiple providers. It abstracts the complexities of working with diverse APIs, configurations, and data formats, providing developers with a unified framework to streamline their workflows.
Key Features of AISuite:
- Straightforward Interface: AISuite offers a simple and consistent interface for managing various LLMs. Developers can integrate models into their applications with just a few lines of code, significantly lowering the barriers to entry for Gen AI projects.
- Unified Framework: By abstracting the differences between multiple APIs, AISuite handles different types of requests and responses seamlessly. This reduces development overhead and accelerates prototyping and deployment.
- Easy Model Switching: With AISuite, switching between models is as easy as changing a single string in the code. For example, developers can specify a “provider:model” combination like openai:gpt-4o or anthropic:claude-3-5 without rewriting significant parts of their application.
- Extensibility: AISuite is designed to adapt to the evolving Gen AI landscape. Developers can add new models and providers as they become available, ensuring applications remain up-to-date with the latest AI capabilities.
Why is AISuite Important?
AISuite addresses a critical pain point in the Gen AI ecosystem: the lack of interoperability between LLMs from different providers. By providing a unified interface, it simplifies the development process, saving time and reducing costs. This flexibility allows teams to optimize performance by selecting the best model for specific tasks.
Early benchmarks and community feedback highlight AISuite’s ability to reduce integration time for multi-model applications, improving developer efficiency and productivity. As the Gen AI ecosystem grows, AISuite lowers barriers for experimenting, building, and scaling AI-powered solutions.
Experimenting with AISuite
Lets get started exploring AISuite by installing necessary dependencies.
Installing dependencies
- Create and activate a virtual environment by executing the following command.
python -m venv venv source venv/bin/activate #for ubuntu venv/Scripts/activate #for windows
- Install aisuite, openai and python-dotenv libraries using pip.
pip install aisuite[all] openai python-dotenv
Setting up environment and credentials
Create a file named .env. This file will store your environment variables, including the OpenAI key.
- Open the .env file and add the following code to specify your OpenAI API key:
OPENAI_API_KEY=sk-proj-7XyPjkdaG_gDl0_... GROQ_API_KEY=gsk_8NIgj24k2P0J5RwrwoOBW...
- Add API keys to the environment variables.
import os from dotenv import load_dotenv load_dotenv() os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY') os.environ['ANTHROPIC_API_KEY'] = getpass('Enter your ANTHROPIC API key: ')
Initialize the AISuite Client
Create an instance of the AISuite client, enabling standardized interaction with multiple LLMs.
python -m venv venv source venv/bin/activate #for ubuntu venv/Scripts/activate #for windows
Querying the model
User can query the model using AISuite as follows.
pip install aisuite[all] openai python-dotenv
- model="openai:gpt-4o": Specifies type and version of the model.
- messages=messages: Sends the previously defined prompt to the model.
- temperature=0.75: Adjusts the randomness of the response. Higher values encourage creative outputs, while lower values produce more deterministic results.
- response.choices[0].message.content: Retrieves the text content from the model's response.
Creating a Chat Completion
Lets create a chat completion code using OpenAI model.
OPENAI_API_KEY=sk-proj-7XyPjkdaG_gDl0_... GROQ_API_KEY=gsk_8NIgj24k2P0J5RwrwoOBW...
- Run the app using the following command.
import os from dotenv import load_dotenv load_dotenv() os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY') os.environ['ANTHROPIC_API_KEY'] = getpass('Enter your ANTHROPIC API key: ')
You will get output as follows,
Creating a generic function for querying
Instead of writing separate code for calling different models, let’s create a generic function to eliminate code repetition and improve efficiency.
client = ai.Client() Defining the prompt The prompt syntax closely resembles OpenAI’s structure, incorporating roles and content. messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Tell a joke in 1 line."} ]
The ask function is a reusable utility designed for sending queries to an AI model. It accepts the following parameters:
- message: The user's query or prompt. sys_message (optional): A system-level instruction to guide the model's behavior.
- model: Specifies the AI model to be used. The function processes the input parameters, sends them to the specified model, and returns the AI’s response, making it a versatile tool for interacting with various models.
Below is the complete code for interacting with the OpenAI model using the generic ask function.
# openai model response = client.chat.completions.create(model="openai:gpt-4o", messages=messages, temperature=0.75) # ollama model response = client.chat.completions.create(model="ollama:llama3.1:8b", messages=messages, temperature=0.75) # anthropic model response = client.chat.completions.create(model="anthropic:claude-3-5-sonnet-20241022", messages=messages, temperature=0.75) # groq model response = client.chat.completions.create(model="groq:llama-3.2-3b-preview", messages=messages, temperature=0.75) print(response.choices[0].message.content)
Running the code will produce the following output.
Interacting with multiple APIs
Let’s explore interacting with multiple models using AISuite through the following code.
import os from dotenv import load_dotenv load_dotenv() os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY') import aisuite as ai client = ai.Client() provider = "openai" model_id = "gpt-4o" messages = [ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Provide an overview of the latest trends in AI"}, ] response = client.chat.completions.create( model = f"{provider}:{model_id}", messages = messages, ) print(response.choices[0].message.content)
There may be challenges when interacting with providers like Anthropic or Groq. Hopefully, the AISuite team is actively addressing these issues to ensure seamless integration and functionality.
AISuite is a powerful tool for navigating the landscape of large language models. It enables users to leverage the strengths of multiple AI providers while streamlining development and encouraging innovation. With its open-source foundation and intuitive design, AISuite stands out as a cornerstone for modern AI application development.
Thanks for reading this article !!
Thanks Gowri M Bhatt for reviewing the content.
If you enjoyed this article, please click on the heart button ♥ and share to help others find it!
The full source code for this tutorial can be found here,
GitHub - codemaker2015/aisuite-examples : github.com
Resources
GitHub - andrewyng/aisuite: Simple, unified interface to multiple Generative AI providers : github.com
The above is the detailed content of AISuite: Simplifying GenAI integration across multiple LLM providers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Python excels in gaming and GUI development. 1) Game development uses Pygame, providing drawing, audio and other functions, which are suitable for creating 2D games. 2) GUI development can choose Tkinter or PyQt. Tkinter is simple and easy to use, PyQt has rich functions and is suitable for professional development.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.

To maximize the efficiency of learning Python in a limited time, you can use Python's datetime, time, and schedule modules. 1. The datetime module is used to record and plan learning time. 2. The time module helps to set study and rest time. 3. The schedule module automatically arranges weekly learning tasks.

Python is better than C in development efficiency, but C is higher in execution performance. 1. Python's concise syntax and rich libraries improve development efficiency. 2.C's compilation-type characteristics and hardware control improve execution performance. When making a choice, you need to weigh the development speed and execution efficiency based on project needs.

Pythonlistsarepartofthestandardlibrary,whilearraysarenot.Listsarebuilt-in,versatile,andusedforstoringcollections,whereasarraysareprovidedbythearraymoduleandlesscommonlyusedduetolimitedfunctionality.

Is it enough to learn Python for two hours a day? It depends on your goals and learning methods. 1) Develop a clear learning plan, 2) Select appropriate learning resources and methods, 3) Practice and review and consolidate hands-on practice and review and consolidate, and you can gradually master the basic knowledge and advanced functions of Python during this period.

Python excels in automation, scripting, and task management. 1) Automation: File backup is realized through standard libraries such as os and shutil. 2) Script writing: Use the psutil library to monitor system resources. 3) Task management: Use the schedule library to schedule tasks. Python's ease of use and rich library support makes it the preferred tool in these areas.

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.
