An (unofficial) python native client for easy interaction with MiniMax Open Platform
Project description
MiniMax Python Client
An (unofficial) python native client for easy interaction with MiniMax Open Platform
The current implementation includes the following official API from MiniMax:
- ChatCompletion v2
Prerequisites
- Python >= 3.8
- pip
- An API KEY acquired from MiniMax Open Platform
Quick Start
Install the package
pip install minimax-client
Import the package and invoke the client
Sync call
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
response = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "1 + 1 equals: ",
}
]
)
print(response.choices[0].message.content)
Sync call with streaming
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
stream = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "1 + 1 equals: ",
}
],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content if chunk.choices[0].delta else "", end="")
Async call
import asyncio
from minimax_client import AsyncMiniMax
async def demo():
client = AsyncMiniMax(api_key="<YOUR_API_KEY>")
response = await client.chat.completions.create(
messages=[
{
"role": "user",
"content": "1 + 1 equals: ",
}
]
)
print(response.choices[0].message.content)
asyncio.run(demo())
Async call with streaming
import asyncio
from minimax_client import AsyncMiniMax
async def demo():
client = AsyncMiniMax(api_key="<YOUR_API_KEY>")
stream = await client.chat.completions.create(
messages=[
{
"role": "user",
"content": "1 + 1 equals: ",
}
],
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content if chunk.choices[0].delta else "", end="")
asyncio.run(demo())
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
minimax_client-0.1.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for minimax_client-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f86a3812414e7f2b0803e6db3b12eb172a5432cbdf0e82aa550a8cd261ac70a5 |
|
MD5 | 830cb23fe25f16d98525e6f01b90c221 |
|
BLAKE2b-256 | e4ebe30d560eb19f35aac681391113c4adba07629a0508d3e8b9225f874c4905 |