Skip to main content

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_KEY
    • OPENAI_API_KEY
    • MINIMAX_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


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.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

motosan_ai-0.2.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file motosan_ai-0.2.0.tar.gz.

File metadata

  • Download URL: motosan_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 8.4 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

Hashes for motosan_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d54e715f6d450662c4d630c845608a4fdf3cb5436a9c834b027093ed9a433d31
MD5 07e338d43d20ed584b8d5405a5e58f8b
BLAKE2b-256 47d78a047eee3ae701e811a0f5ee868a55386e2145d12b11c57fe41f83e463b5

See more details on using hashes here.

File details

Details for the file motosan_ai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: motosan_ai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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

Hashes for motosan_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 589287752135cb7e8db4cc9b024591b0b9d04228e08b5baefd92723219dd4ea8
MD5 c6814677577277d0a28cc1146d78534e
BLAKE2b-256 54cec50d315813a17b4b8f85bd00b959ad20d4f9445530d96a48062630f8661e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page