Meet aisuite: A New Open-Source Tool from Andrew Ng to Simplify Multi-Provider AI Integration
Recently, Andrew Ng, Founder of DeepLearning.AI, announced aisuite, an open-source Python package for large language models (LLMs), I was immediately intrigued. Designed to streamline the use of LLMs across multiple providers, aisuite addresses a problem many developers, myself included, face when building AI-driven applications: the hassle of integrating with different providers.
With aisuite, you can specify a "provider:model" like openai:gpt-4o
, anthropic:claude-3-5-sonnet-20241022
, or ollama:llama3.1:8b
just by changing one string.
For Google models, you can use google:palm-2
(a closed-source model from Google Cloud) or even experiment with open-source models hosted on Google’s platforms, such as t5-large
via HuggingFace or flan-t5
. This flexibility allows you to seamlessly integrate both proprietary and open-source models into your workflows, all while using the same standardized interface.
No more fiddling with separate SDKs or API configurations. This simplicity makes aisuite a game-changer for comparing and deploying models efficiently.
Let me walk you through how this works with a real-life coding example!
Why aisuite is a Big Deal
Andrew Ng’s vision for aisuite is clear: to enable developers to innovate faster by removing the friction of working with multiple providers. Here’s why it’s worth your attention:
Unified Interface: Use the same API to interact with LLMs from different providers.
Quick Model Swaps: Change models by updating a single string.
Comparison Made Easy: Run side-by-side tests to see which model fits your use case best.
Scalable Integration: Supports top providers like OpenAI, Anthropic, Google, HuggingFace, and more.
Whether you’re prototyping or deploying production-grade applications, aisuite’s flexibility and ease of use can save you time and headaches.
Setting Up aisuite
Before we jump into the code, here’s how you can get started.
Install aisuite
You can install just the base package or include dependencies for specific providers.
Base package only:
bash
pip install aisuite
With Anthropic’s SDK:
bash
pip install aisuite[anthropic]
All providers’ SDKs:
bash
pip install aisuite[all]
Set API Keys
You’ll need API keys for the providers you plan to use. These can be set as environment variables:
bash
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"
Alternatively, you can pass the keys directly when initializing the client.
Real-Life Example: Comparing Models
Here’s an example that highlights the power of aisuite. Let’s prompt models from OpenAI and Anthropic to generate jokes in Pirate English.
python
import aisuite as ai
# Initialize the aisuite client
client = ai.Client()
# Define the models we want to use
models = [
"openai:gpt-4o",
"anthropic:claude-3-5-sonnet-20241022"
]
# Define the context for the conversation
messages = [
{"role": "system", "content": "Respond in Pirate English."},
{"role": "user", "content": "Tell me a joke."},
]
# Get and print responses from each model
for model in models:
response = client.chat.completions.create(
model=model,
messages=messages,
temperature=0.75
)
print(f"Response from {model}:\n{response.choices[0].message.content}\n")
What’s Happening in the Code?
We initialize the
aisuite
client.Define the models using the
provider:model
format.Craft a message prompting the models to respond in Pirate English.
Loop through the models and call the
chat.completions.create
method to get responses.
With aisuite, swapping models or adding a new one is as easy as updating the models
list.
Practical Applications
This unified approach is invaluable for:
Model Evaluation: Compare responses across providers to select the best fit.
Prototyping: Quickly test ideas with different models during development.
Cost Optimization: Dynamically choose models based on budget and performance.
Task Specialization: Use the best model for specific tasks like summarization, translation, or creative writing.
Conclusion
aisuite is a powerful addition to the AI developer’s toolkit, simplifying the complexity of multi-provider LLM integration. Whether you’re testing models for a research project or deploying an application at scale, aisuite lets you focus on building great products instead of wrestling with integration details.
Andrew Ng’s contribution to the open-source AI ecosystem keeps pushing the boundaries of what’s possible. I highly recommend giving aisuite a try—you might just find it as transformative as I did.
Have you experimented with aisuite? Share your use cases or feedback in the comments below!
The link to the repo is here.
Find more examples here, experiment, and share your insights in the comments.
Happy AI Coding,
Kemal
Great post! Seems like a really cool tool for AI engineers :D