Python SDK for Anthropic, OpenAI, and MiniMax AI providers
Project description
motosan-ai (Python SDK)
Multi-provider Python SDK for Anthropic, OpenAI, and MiniMax.
Installation
pip install motosan-ai
pip install "motosan-ai[anthropic]"
pip install "motosan-ai[openai]"
pip install "motosan-ai[minimax]"
pip install "motosan-ai[full]"
Quick Start
import asyncio
from motosan_ai import Client
async def main() -> None:
client = Client.anthropic(api_key="sk-ant-...", model="claude-3-5-sonnet-latest")
response = await client.chat([
{"role": "user", "content": "Hello"},
])
print(response.content)
asyncio.run(main())
Tool Use (Multi-turn)
import asyncio
from motosan_ai import Client, Message, Tool
def get_weather(city: str) -> str:
return f"Sunny in {city}"
async def main() -> None:
client = Client.anthropic(api_key="sk-ant-...")
tools = [
Tool(
name="get_weather",
description="Get current weather",
input_schema={
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
)
]
messages = [Message.user("What's the weather in Tokyo?")]
response = await client.chat(messages, tools=tools)
if response.tool_calls:
tc = response.tool_calls[0]
result = get_weather(tc.input["city"])
messages += [
Message.assistant_with_tool_calls("", response.tool_calls),
Message.tool_result(tc.id, result),
]
final = await client.chat(messages, tools=tools)
print(final.content)
asyncio.run(main())
Streaming
import asyncio
from motosan_ai import Client, Message
async def main() -> None:
client = Client.openai(api_key="sk-...", model="gpt-4.1-mini")
async for event in client.stream([Message.user("Write a haiku about rain")]):
if event.content:
print(event.content, end="")
if event.done:
break
asyncio.run(main())
Sync Wrapper
from motosan_ai import Client, Message
client = Client.minimax(api_key="...")
response = client.chat_sync([Message.user("Hello from sync")])
print(response.content)
Providers
Anthropic
from motosan_ai import Client
client = Client.anthropic(api_key="sk-ant-...", model="claude-3-5-sonnet-latest")
OpenAI
from motosan_ai import Client
client = Client.openai(api_key="sk-...", model="gpt-4.1-mini")
MiniMax
from motosan_ai import Client
client = Client.minimax(api_key="...", model="MiniMax-M1")
Requirements
- Python 3.11+
- One provider API key:
ANTHROPIC_API_KEYOPENAI_API_KEYMINIMAX_API_KEY
Development
uv sync --extra full --extra dev
uv run ruff check motosan_ai/
uv run pytest -q
uv build --out-dir dist
uv publish --dry-run dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
motosan_ai-0.2.1.tar.gz
(11.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file motosan_ai-0.2.1.tar.gz.
File metadata
- Download URL: motosan_ai-0.2.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
896ef595e8719965e741d266419b110564213babb7268a5cadeeb71741440a6b
|
|
| MD5 |
897b629c435474a27ebe0f758a09f1ba
|
|
| BLAKE2b-256 |
fcfbf268c5293fc89761d4cfc78c85e92c4a7d0f3c764eb0dd2e906454f71be5
|
File details
Details for the file motosan_ai-0.2.1-py3-none-any.whl.
File metadata
- Download URL: motosan_ai-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e44848e2cb6f27507a13af6902b9ffbaa63a7f4383a40ec1a9a377c0fe133d13
|
|
| MD5 |
2179cb38b1f520f18c56cf3d334a4085
|
|
| BLAKE2b-256 |
d42bc68055e84ef5690d2ccc932e8af2d0140c985ffcfc8b0e0342e5f71e05ed
|