[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71921":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},71921,"aisuite","andrewyng\u002Faisuite","andrewyng","Simple, unified interface to multiple Generative AI providers ",null,"Python",13807,1456,173,64,0,4,23,45,12,93.49,"MIT License",false,"main",[],"2026-06-12 04:01:02","#  aisuite\n\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Faisuite)](https:\u002F\u002Fpypi.org\u002Fproject\u002Faisuite\u002F)\n[![Code style: black](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fcode%20style-black-000000.svg)](https:\u002F\u002Fgithub.com\u002Fpsf\u002Fblack)\n\n`aisuite` is a lightweight Python library that provides a **unified API for working with multiple Generative AI providers**.  \nIt offers a consistent interface for models from *OpenAI, Anthropic, Google, Hugging Face, AWS, Cohere, Mistral, Ollama*, and others—abstracting away SDK differences, authentication details, and parameter variations.  \nIts design is modeled after OpenAI’s API style, making it instantly familiar and easy to adopt.\n\n`aisuite` lets developers build and **run LLM-based or agentic applications across providers** with minimal setup.  \nWhile it’s not a full-blown agents framework, it includes simple abstractions for creating standalone, lightweight agents.  \nIt’s designed for low learning curve — so you can focus on building AI systems, not integrating APIs.\n\n---\n\n## Key Features\n\n`aisuite` is designed to eliminate the complexity of working with multiple LLM providers while keeping your code simple and portable. Whether you're building a chatbot, an agentic application, or experimenting with different models, `aisuite` provides the abstractions you need without getting in your way.\n\n* **Unified API for multiple model providers** – Write your code once and run it with any supported provider. Switch between OpenAI, Anthropic, Google, and others with a single parameter change.\n* **Easy agentic app or agent creation** – Build multi-turn agentic applications using a single parameter `max_turns`. No need to manually manage tool execution loops.\n* **Pass Tool calls easily** – Pass real Python functions instead of JSON specs; aisuite handles schema generation and execution automatically.\n* **MCP tools** – Connect to MCP-based tools without writing boilerplate; aisuite handles connection, schema and execution seamlessly.\n* **Modular and extensible provider architecture** – Add support for new providers with minimal code. The plugin-style architecture makes extensions straightforward.\n\n---\n\n## Installation\n\nYou can install just the base `aisuite` package, or install a provider's package along with `aisuite`.\n\nInstall just the base package without any provider SDKs:\n\n```shell\npip install aisuite\n```\n\nInstall aisuite with a specific provider (e.g., Anthropic):\n\n```shell\npip install 'aisuite[anthropic]'\n```\n\nInstall aisuite with all provider libraries:\n\n```shell\npip install 'aisuite[all]'\n```\n\n## Setup\n\nTo get started, you will need API Keys for the providers you intend to use. You'll need to\ninstall the provider-specific library either separately or when installing aisuite.\n\nThe API Keys can be set as environment variables, or can be passed as config to the aisuite Client constructor.\nYou can use tools like [`python-dotenv`](https:\u002F\u002Fpypi.org\u002Fproject\u002Fpython-dotenv\u002F) or [`direnv`](https:\u002F\u002Fdirenv.net\u002F) to set the environment variables manually. Please take a look at the `examples` folder to see usage.\n\nHere is a short example of using `aisuite` to generate chat completion responses from gpt-4o and claude-3-5-sonnet.\n\nSet the API keys.\n\n```shell\nexport OPENAI_API_KEY=\"your-openai-api-key\"\nexport ANTHROPIC_API_KEY=\"your-anthropic-api-key\"\n```\n\nUse the python client.\n\n```python\nimport aisuite as ai\nclient = ai.Client()\n\nmodels = [\"openai:gpt-4o\", \"anthropic:claude-3-5-sonnet-20240620\"]\n\nmessages = [\n    {\"role\": \"system\", \"content\": \"Respond in Pirate English.\"},\n    {\"role\": \"user\", \"content\": \"Tell me a joke.\"},\n]\n\nfor model in models:\n    response = client.chat.completions.create(\n        model=model,\n        messages=messages,\n        temperature=0.75\n    )\n    print(response.choices[0].message.content)\n\n```\n\nNote that the model name in the create() call uses the format - `\u003Cprovider>:\u003Cmodel-name>`.\n`aisuite` will call the appropriate provider with the right parameters based on the provider value.\nFor a list of provider values, you can look at the directory - `aisuite\u002Fproviders\u002F`. The list of supported providers are of the format - `\u003Cprovider>_provider.py` in that directory. We welcome providers to add support to this library by adding an implementation file in this directory. Please see section below for how to contribute.\n\nFor more examples, check out the `examples` directory where you will find several notebooks that you can run to experiment with the interface.\n\n---\n\n## Chat Completions\n\nThe chat API provides a high-level abstraction for model interactions. It supports all core parameters (`temperature`, `max_tokens`, `tools`, etc.) in a provider-agnostic way.\n\n```python\nresponse = client.chat.completions.create(\n    model=\"google:gemini-pro\",\n    messages=[{\"role\": \"user\", \"content\": \"Summarize this paragraph.\"}],\n)\nprint(response.choices[0].message.content)\n```\n\n`aisuite` standardizes request and response structures so you can focus on logic rather than SDK differences.\n\n---\n\n## Tool Calling & Agentic apps\n\n`aisuite` provides a simple abstraction for tool\u002Ffunction calling that works across supported providers. This is in addition to the regular abstraction of passing JSON spec of the tool to the `tools` parameter. The tool calling abstraction makes it easy to use tools with different LLMs without changing your code.\n\nThere are two ways to use tools with `aisuite`:\n\n### 1. Manual Tool Handling\n\nThis is the default behavior when `max_turns` is not specified. In this mode, you have full control over the tool execution flow. You pass tools using the standard OpenAI JSON schema format, and `aisuite` returns the LLM's tool call requests in the response. You're then responsible for executing the tools, processing results, and sending them back to the model in subsequent requests.\n\nThis approach is useful when you need:\n- Fine-grained control over tool execution logic\n- Custom error handling or validation before executing tools\n- The ability to selectively execute or skip certain tool calls\n- Integration with existing tool execution pipelines\n\nYou can pass tools in the OpenAI tool format:\n\n```python\ndef will_it_rain(location: str, time_of_day: str):\n    \"\"\"Check if it will rain in a location at a given time today.\n    \n    Args:\n        location (str): Name of the city\n        time_of_day (str): Time of the day in HH:MM format.\n    \"\"\"\n    return \"YES\"\n\ntools = [{\n    \"type\": \"function\",\n    \"function\": {\n        \"name\": \"will_it_rain\",\n        \"description\": \"Check if it will rain in a location at a given time today\",\n        \"parameters\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"location\": {\n                    \"type\": \"string\",\n                    \"description\": \"Name of the city\"\n                },\n                \"time_of_day\": {\n                    \"type\": \"string\",\n                    \"description\": \"Time of the day in HH:MM format.\"\n                }\n            },\n            \"required\": [\"location\", \"time_of_day\"]\n        }\n    }\n}]\n\nresponse = client.chat.completions.create(\n    model=\"openai:gpt-4o\",\n    messages=messages,\n    tools=tools\n)\n```\n\n### 2. Automatic Tool Execution\n\nWhen `max_turns` is specified, you can pass a list of callable Python functions as the `tools` parameter. `aisuite` will automatically handle the tool calling flow:\n\n```python\ndef will_it_rain(location: str, time_of_day: str):\n    \"\"\"Check if it will rain in a location at a given time today.\n    \n    Args:\n        location (str): Name of the city\n        time_of_day (str): Time of the day in HH:MM format.\n    \"\"\"\n    return \"YES\"\n\nclient = ai.Client()\nmessages = [{\n    \"role\": \"user\",\n    \"content\": \"I live in San Francisco. Can you check for weather \"\n               \"and plan an outdoor picnic for me at 2pm?\"\n}]\n\n# Automatic tool execution with max_turns\nresponse = client.chat.completions.create(\n    model=\"openai:gpt-4o\",\n    messages=messages,\n    tools=[will_it_rain],\n    max_turns=2  # Maximum number of back-and-forth tool calls\n)\nprint(response.choices[0].message.content)\n```\n\nWhen `max_turns` is specified, `aisuite` will:\n1. Send your message to the LLM\n2. Execute any tool calls the LLM requests\n3. Send the tool results back to the LLM\n4. Repeat until the conversation is complete or max_turns is reached\n\nIn addition to `response.choices[0].message`, there is an additional field `response.choices[0].intermediate_messages` which contains the list of all messages including tool interactions used. This can be used to continue the conversation with the model.\nFor more detailed examples of tool calling, check out the `examples\u002Ftool_calling_abstraction.ipynb` notebook.\n\n### Model Context Protocol (MCP) Integration\n\n`aisuite` natively supports **MCP**, a standard protocol that allows LLMs to securely call external tools and access data. You can connect to MCP servers—such as a filesystem or database—and expose their tools directly to your model.\nRead more about MCP here - https:\u002F\u002Fmodelcontextprotocol.io\u002Fdocs\u002Fgetting-started\u002Fintro\n\nInstall aisuite with MCP support:\n\n```shell\npip install 'aisuite[mcp]'\n```\n\nYou'll also need an MCP server. For example, to use the filesystem server:\n\n```shell\nnpm install -g @modelcontextprotocol\u002Fserver-filesystem\n```\n\nThere are two ways to use MCP tools with aisuite:\n\n#### Option 1: Config Dict Format (Recommended for Simple Use Cases)\n\n```python\nimport aisuite as ai\n\nclient = ai.Client()\nresponse = client.chat.completions.create(\n    model=\"openai:gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"List the files in the current directory\"}],\n    tools=[{\n        \"type\": \"mcp\",\n        \"name\": \"filesystem\",\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"@modelcontextprotocol\u002Fserver-filesystem\", \"\u002Fpath\u002Fto\u002Fdirectory\"]\n    }],\n    max_turns=3\n)\n\nprint(response.choices[0].message.content)\n```\n\n#### Option 2: Explicit MCPClient (Recommended for Advanced Use Cases)\n\n```python\nimport aisuite as ai\nfrom aisuite.mcp import MCPClient\n\n# Create MCP client once, reuse across requests\nmcp = MCPClient(\n    command=\"npx\",\n    args=[\"-y\", \"@modelcontextprotocol\u002Fserver-filesystem\", \"\u002Fpath\u002Fto\u002Fdirectory\"]\n)\n\n# Use with aisuite\nclient = ai.Client()\nresponse = client.chat.completions.create(\n    model=\"openai:gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"List the files\"}],\n    tools=mcp.get_callable_tools(),\n    max_turns=3\n)\n\nprint(response.choices[0].message.content)\nmcp.close()  # Clean up\n```\n\nFor detailed usage (security filters, tool prefixing, and `MCPClient` management), see [docs\u002Fmcp-tools.md](docs\u002Fmcp-tools.md).\nFor detailed examples, see `examples\u002Fmcp_tools_example.ipynb`.\n\n---\n\n## Extending aisuite: Adding a Provider\n\nNew providers can be added by implementing a lightweight adapter. The system uses a naming convention for discovery:\n\n| Element         | Convention                         |\n| --------------- | ---------------------------------- |\n| **Module file** | `\u003Cprovider>_provider.py`           |\n| **Class name**  | `\u003CProvider>Provider` (capitalized) |\n\nExample:\n\n```python\n# providers\u002Fopenai_provider.py\nclass OpenaiProvider(BaseProvider):\n    ...\n```\n\nThis convention ensures consistency and enables automatic loading of new integrations.\n\n---\n\n## Contributing\n\nContributions are welcome. Please review the [Contributing Guide](https:\u002F\u002Fgithub.com\u002Fandrewyng\u002Faisuite\u002Fblob\u002Fmain\u002FCONTRIBUTING.md) and join our [Discord](https:\u002F\u002Fdiscord.gg\u002FT6Nvn8ExSb) for discussions.\n\n---\n\n## License\n\nReleased under the **MIT License** — free for commercial and non-commercial use.\n\n---\n","aisuite 是一个轻量级的 Python 库，提供了一个统一的接口来操作多个生成式 AI 服务提供商。它支持包括 OpenAI、Anthropic、Google、Hugging Face 等在内的多个模型，并抽象了不同 SDK 的差异、认证细节和参数变化，使开发者能够以一致的方式使用这些模型。此外，aisuite 提供了简单的代理创建功能，方便构建多轮对话的应用程序。该库特别适合需要跨平台运行基于大语言模型或代理应用的场景，如开发聊天机器人或多轮交互系统。通过 aisuite，用户可以专注于业务逻辑的实现，而无需过多关注底层 API 的集成问题。",2,"2026-06-11 03:39:28","high_star"]