SuperAPI AI Directory

aisuite - Andrew Ng Releases Open-Source Python Library, One Interface to Call Multiple Large Models

Author: AI小集 · Original source: AI工具集

What is aisuite

aisuite is an open-source Python library released by Andrew Ng, designed to provide a unified interface for calling multiple large language model (LLM) services. It supports 11 model platforms including OpenAI, Anthropic, Azure, etc., allowing developers to easily switch and test models from different providers. Through aisuite, users can conveniently obtain API keys and set environment variables to access and call different language models. It simplifies the work of multi-model management and testing, promoting the application and development of artificial intelligence technology.

Main Features of aisuite

  • Unified Interface Design: aisuite provides a unified interface, allowing developers to call models from different large language model (LLM) platforms in the same way.
  • Supports Multiple Model Platforms: aisuite supports multiple model platforms including OpenAI, Anthropic, Azure, Google, AWS, Groq, Mistral, HuggingFace, and Ollama.
  • Simplified Model Switching: Users only need to change one string to select models from different providers, greatly simplifying the process of model switching and comparative testing.
  • Easy to Install and Configure: The installation process of aisuite is simple. Users only need to prepare a Python environment and the required API keys, and can install the framework through simple commands.
  • Main Focus on Chat Functionality: Currently, aisuite mainly focuses on enhancing chat functionality, with plans to expand to more usage scenarios in the future.
  • Extensibility: aisuite plans to add more functional modules, such as function calling, to further enrich its practicality.
  • Use HTTP Endpoints or SDK Calls: To ensure stability, aisuite uses HTTP endpoints or SDKs to make calls with providers.

aisuite Project Address

How to Use aisuite

  • Install aisuite: aisuite can be installed via the pip command.
    • Install only the base package, without any provider SDKs, using the commandpip install aisuite。
    • If you need support for a specific provider, such as Anthropic, you can use the commandpip install 'aisuite (anthropic)'。
    • To install all provider-specific libraries, use the commandpip install 'aisuite (all)'。
  • Obtain API Keys: After installation, you need to obtain API keys for the selected provider and configure them through environment variables.
  • Write a Python Client: After configuring the API keys, you can use a standard Python client to request features such as chat completion. For example, the following is an example Python client code for generating chat completion responses using aisuite:
    import aisuite as ai
    client = ai.Client()
    models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20241022"]
    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)

Application Scenarios of aisuite

  • Chat Completion Functionality: Currently, aisuite mainly focuses on chat completion functionality, supporting developers in calling different models through a unified interface to generate chat responses.
  • Model Comparative Testing: aisuite supports quickly switching between different models by simply changing one string, for example, from "openai:gpt-4o" to "anthropic:claude-3-5-sonnet-20241022", making model comparative testing simple.
  • Personalized Recommendations and Services: aisuite can provide personalized recommendations and services to users by analyzing user behavior and preferences, such as product recommendations on e-commerce platforms and social recommendations on social media.
  • Build a chat UI interface: With tools such as Streamlit, aisuite can be used to build a simple chat UI interface, further expanding its application in the field of user interaction.