Name | minimax-client JSON |
Version |
0.6.2
JSON |
| download |
home_page | None |
Summary | An (unofficial) python native client for easy interaction with MiniMax Open Platform |
upload_time | 2024-10-11 07:45:00 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT |
keywords |
web
ai
api
llm
nlp
minimax
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# MiniMax Python Client
[![PyPI version](https://img.shields.io/pypi/v/minimax-client.svg)](https://pypi.org/project/minimax-client/)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm-project.org)
[![License](https://img.shields.io/pypi/l/minimax-client.svg)](https://pypi.org/project/minimax-client)
[![python-versions](https://img.shields.io/pypi/pyversions/minimax-client.svg)](https://pypi.org/project/minimax-client)
[![Main Workflow](https://github.com/linzeyang/minimax-python-client/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/linzeyang/minimax-python-client/actions/workflows/main.yml)
An (unofficial) python native client for easy interaction with [MiniMax Open Platform](https://www.minimaxi.com/platform)
The current implementation includes the following official APIs offered by MiniMax:
- ChatCompletion v2
- Embeddings
- File
- Finetune
- Assistants
- Assistant
- Assistant File
- Thread
- Message
- Run
- Run Step
- Audio
- T2A
- T2A Pro
- T2A Large
- T2A Stream
- Voice Cloning
## Prerequisites
- Python >= 3.8
- pip (or any other tool that does the same job)
- Internet connection
- An API KEY acquired from [MiniMax Open Platform](https://www.minimaxi.com/user-center/basic-information/interface-key)
## Quick Start
### 1. Install the package
```bash
pip install minimax-client
```
### 2. Import the package and invoke the client
#### 2.1 Sync call
```python
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)
```
#### 2.2 Sync call with streaming
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
stream = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "What is the term GPT short for?",
}
],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content if chunk.choices[0].delta else "", end="")
```
#### 2.3 Sync call with tools, stream enabled
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
stream = client.chat.completions.create(
model="abab5.5-chat",
messages=[
{
"role": "system",
"content": "You are a helpful assistant",
},
{
"role": "user",
"content": "What's the weather like in Log Angeles right now?",
},
{
"role": "assistant",
"tool_calls": [
{
"id": "call_function_2936815621",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": '{"location": "LogAngeles"}',
},
}
],
},
{
"role": "tool",
"tool_call_id": "call_function_2936815621",
"content": "LogAngeles / Sunny / 51°F / Wind: East 5 mph",
},
],
stream=True,
tool_choice="auto",
tools=[
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Retrieve the current weather of given location",
"parameters": '{"type": "object", "properties": {"location": {"type": "string", "description": "Name of a city, eg. Paris, London"}}, "required": ["location"]}',
},
}
],
)
for chunk in stream:
print(chunk.choices[0].delta.content if chunk.choices[0].delta else "", end="")
# It's currently sunny in Log Angeles, with a temperature of 51°F and wind from the east at 5 mph.
```
#### 2.4 Async call
```python
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())
```
#### 2.5 Async call with streaming
```python
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": "What is the term GPT short for?",
}
],
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content if chunk.choices[0].delta else "", end="")
asyncio.run(demo())
```
#### 2.6 Sync call for embeddings
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
response = client.embeddings.create(
input=["Hello world!", "Nice to meet you!"],
target="db",
)
print(response.vectors[0][:10])
print(response.vectors[1][:10])
```
#### 2.7 Async call for embeddings
```python
import asyncio
from minimax_client import AsyncMiniMax
async def demo():
client = AsyncMiniMax(api_key="<YOUR_API_KEY>")
response = await client.embeddings.create(
input=["Hello async world!", "Nice to meet you async!"],
target="query",
)
print(response.vectors[0][:10])
print(response.vectors[1][:10])
asyncio.run(demo())
```
#### 2.8 Sync call for files
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.files.create(filepath="sample.txt", purpose="retrieval")
print(resp.file.file_id)
resp = client.files.list(purpose="retrieval")
print(resp.files[0].file_id)
resp = client.files.retrieve(file_id=resp.files[0].file_id)
print(resp.file.bytes)
resp = client.files.delete(file_id=resp.file.file_id)
print(resp.file_id)
```
#### 2.9 Async call for files
```python
import asyncio
from minimax_client import AsyncMiniMax
async def demo():
client = AsyncMiniMax(api_key="<YOUR_API_KEY>")
resp = await client.files.create(filepath="sample.txt", purpose="retrieval")
print(resp.file.file_id)
resp = await client.files.list(purpose="retrieval")
print(resp.files[0].file_id)
resp = await client.files.retrieve(file_id=resp.files[0].file_id)
print(resp.file.bytes)
resp = await client.files.delete(file_id=resp.file.file_id)
print(resp.file_id)
asyncio.run(demo())
```
#### 2.10 Sync call for files
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.fine_tuning.jobs.create(
model="abab5.5s-chat-240123", training_file=..., suffix="test"
)
print(resp.id)
print(resp.fine_tuned_model)
resp = client.fine_tuning.jobs.list(limit=5)
print(resp.job_list[0])
resp = client.model.list()
print(resp.model_list[0])
resp = client.model.retrieve(model="ft:abab5.5s-chat-240123_XXXXXXXXXXXXX:test")
print(resp.model.id)
```
#### 2.11 Sync call for assistants
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.assistants.create(model="abab5.5s-chat-240123")
client.assistants.update(
assistant_id=resp.id,
model="abab5.5s-chat-240123",
name="test-assistant",
instructions="You are a helpful assistant.",
)
client.assistants.retrieve(assistant_id=resp.id)
client.assistants.list(limit=5)
client.assistants.delete(assistant_id=resp.id)
```
#### 2.12 Sync call for assistant files
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.files.create(filepath="sample.txt", purpose="retrieval")
file_id = resp.file.file_id
resp = client.assistants.create(
model="abab5.5s-chat-240123",
name="test-assistant",
instructions="You are a helpful assistant.",
description="test-assistant",
tools=[{"type": "retrieval"}],
)
assistant_id = resp.id
resp = client.assistants.files.create(assistant_id=assistant_id, file_id=str(file_id))
resp = client.assistants.files.retrieve(assistant_id=assistant_id, file_id=str(file_id))
resp = client.assistants.files.list(assistant_id=assistant_id, limit=5, order="asc")
resp = client.assistants.files.delete(assistant_id=assistant_id, file_id=str(file_id))
```
#### 2.13 Sync call for assistant threads
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.threads.create(metadata={"key": "value"})
resp = client.threads.retrieve(thread_id=resp.id)
resp = client.threads.update(thread_id=resp.id, metadata={"key": "value2"})
```
#### 2.14 Sync call for assistant messages
```python
import time
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.threads.create(metadata={"key": "value"})
thread_id = resp.id
resp = client.threads.messages.create(
thread_id=thread_id, content="Hello", role="user", metadata={"key": "value"}
)
resp = client.threads.messages.retrieve(thread_id=thread_id, message_id=resp.id)
resp = client.threads.messages.list(thread_id=thread_id, limit=5, order="asc")
```
#### 2.15 Sync call for assistant runs and run steps
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.assistants.create(
model="abab5.5-chat",
name="test-assistant",
instructions="You are a helpful assistant that can use tools to answer questions.",
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"description": "get weather",
"parameters": {
"type": "object",
"required": ["city"],
"properties": {"city": {"type": "string"}},
},
},
},
{"type": "web_search"},
{"type": "code_interpreter"},
],
)
assistant_id = resp.id
resp = client.assistants.retrieve(assistant_id=assistant_id)
print(resp.model_dump())
resp = client.threads.create(metadata={"key1": "value1"})
thread_id = resp.id
client.threads.messages.create(
thread_id=thread_id,
role="user",
content="In the science-fiction 'Three-Body Problem', what is the profession of Wang Miao?",
)
resp = client.threads.runs.create(thread_id=thread_id, assistant_id=assistant_id)
run_id = resp.id
time.sleep(10)
resp = client.threads.runs.retrieve(run_id=run_id, thread_id=thread_id)
print(resp.model_dump())
resp = client.threads.runs.steps.list(thread_id=thread_id, run_id=run_id, limit=10)
for step in resp.data:
resp = client.threads.runs.steps.retrieve(
step_id=step.id, thread_id=thread_id, run_id=run_id
)
print(resp.model_dump())
```
#### 2.16 Sync call for assistant STREAMED runs and run steps
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.assistants.create(
model="abab5.5-chat",
name="test-assistant",
instructions="You are a helpful assistant.",
)
assistant_id = resp.id
resp = client.threads.create(metadata={"key1": "value1"})
thread_id = resp.id
for part in client.threads.runs.stream(
stream_mode=1,
thread_id=thread_id,
assistant_id=assistant_id,
messages=[{"type": 1, "role": "user", "content": "1 + 1 equals:"}],
):
print(part.data.model_dump())
print("\n-----\n")
```
#### 2.17 Sync T2A
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.audio.speech(
text="One apple a day keeps the doctor away",
model="speech-02",
timber_weights=[
{
"voice_id": "male-qn-qingse",
"weight": 1,
},
{
"voice_id": "presenter_female",
"weight": 1,
},
],
vol=1,
pitch=2,
)
if isinstance(resp, bytes):
with open("speech.mp3", "wb") as f:
f.write(resp)
else:
print(resp.model_dump())
```
#### 2.18 Sync Voice Cloning
```python
from minimax_client import MiniMax
client = MiniMax(api_key="<YOUR_API_KEY>")
resp = client.files.create(filepath="original_voice.mp3", purpose="voice_clone")
file_id = resp.file.file_id
resp = client.audio.voice_cloning(
file_id=file_id,
voice_id="cloned12345678",
)
print(resp.model_dump())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "minimax-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "web, ai, api, llm, nlp, minimax",
"author": null,
"author_email": "Zeyang Lin <4020306+linzeyang@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/ae/1d/61ae821b16460795efe8d7e1daad6914d0da9ca96ddef2e5c0d12848ec8f/minimax_client-0.6.2.tar.gz",
"platform": null,
"description": "# MiniMax Python Client\n\n[![PyPI version](https://img.shields.io/pypi/v/minimax-client.svg)](https://pypi.org/project/minimax-client/)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm-project.org)\n[![License](https://img.shields.io/pypi/l/minimax-client.svg)](https://pypi.org/project/minimax-client)\n[![python-versions](https://img.shields.io/pypi/pyversions/minimax-client.svg)](https://pypi.org/project/minimax-client)\n[![Main Workflow](https://github.com/linzeyang/minimax-python-client/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/linzeyang/minimax-python-client/actions/workflows/main.yml)\n\nAn (unofficial) python native client for easy interaction with [MiniMax Open Platform](https://www.minimaxi.com/platform)\n\nThe current implementation includes the following official APIs offered by MiniMax:\n\n- ChatCompletion v2\n- Embeddings\n- File\n- Finetune\n- Assistants\n - Assistant\n - Assistant File\n - Thread\n - Message\n - Run\n - Run Step\n- Audio\n - T2A\n - T2A Pro\n - T2A Large\n - T2A Stream\n - Voice Cloning\n\n## Prerequisites\n\n- Python >= 3.8\n- pip (or any other tool that does the same job)\n- Internet connection\n- An API KEY acquired from [MiniMax Open Platform](https://www.minimaxi.com/user-center/basic-information/interface-key)\n\n## Quick Start\n\n### 1. Install the package\n\n```bash\npip install minimax-client\n```\n\n### 2. Import the package and invoke the client\n\n#### 2.1 Sync call\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\n\nresponse = client.chat.completions.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"1 + 1 equals: \",\n }\n ]\n)\n\n\nprint(response.choices[0].message.content)\n```\n\n#### 2.2 Sync call with streaming\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\n\nstream = client.chat.completions.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"What is the term GPT short for?\",\n }\n ],\n stream=True,\n)\n\n\nfor chunk in stream:\n print(chunk.choices[0].delta.content if chunk.choices[0].delta else \"\", end=\"\")\n```\n\n#### 2.3 Sync call with tools, stream enabled\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\n\nstream = client.chat.completions.create(\n model=\"abab5.5-chat\",\n messages=[\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant\",\n },\n {\n \"role\": \"user\",\n \"content\": \"What's the weather like in Log Angeles right now?\",\n },\n {\n \"role\": \"assistant\",\n \"tool_calls\": [\n {\n \"id\": \"call_function_2936815621\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": '{\"location\": \"LogAngeles\"}',\n },\n }\n ],\n },\n {\n \"role\": \"tool\",\n \"tool_call_id\": \"call_function_2936815621\",\n \"content\": \"LogAngeles / Sunny / 51\u00b0F / Wind: East 5 mph\",\n },\n ],\n stream=True,\n tool_choice=\"auto\",\n tools=[\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Retrieve the current weather of given location\",\n \"parameters\": '{\"type\": \"object\", \"properties\": {\"location\": {\"type\": \"string\", \"description\": \"Name of a city, eg. Paris, London\"}}, \"required\": [\"location\"]}',\n },\n }\n ],\n)\n\nfor chunk in stream:\n print(chunk.choices[0].delta.content if chunk.choices[0].delta else \"\", end=\"\")\n\n# It's currently sunny in Log Angeles, with a temperature of 51\u00b0F and wind from the east at 5 mph.\n```\n\n#### 2.4 Async call\n\n```python\nimport asyncio\n\nfrom minimax_client import AsyncMiniMax\n\n\nasync def demo():\n client = AsyncMiniMax(api_key=\"<YOUR_API_KEY>\")\n\n response = await client.chat.completions.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"1 + 1 equals: \",\n }\n ]\n )\n\n print(response.choices[0].message.content)\n\n\nasyncio.run(demo())\n```\n\n#### 2.5 Async call with streaming\n\n```python\nimport asyncio\n\nfrom minimax_client import AsyncMiniMax\n\n\nasync def demo():\n client = AsyncMiniMax(api_key=\"<YOUR_API_KEY>\")\n\n stream = await client.chat.completions.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"What is the term GPT short for?\",\n }\n ],\n stream=True,\n )\n\n async for chunk in stream:\n print(chunk.choices[0].delta.content if chunk.choices[0].delta else \"\", end=\"\")\n\n\nasyncio.run(demo())\n```\n\n#### 2.6 Sync call for embeddings\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\n\nresponse = client.embeddings.create(\n input=[\"Hello world!\", \"Nice to meet you!\"],\n target=\"db\",\n)\n\nprint(response.vectors[0][:10])\nprint(response.vectors[1][:10])\n```\n\n#### 2.7 Async call for embeddings\n\n```python\nimport asyncio\n\nfrom minimax_client import AsyncMiniMax\n\n\nasync def demo():\n client = AsyncMiniMax(api_key=\"<YOUR_API_KEY>\")\n\n response = await client.embeddings.create(\n input=[\"Hello async world!\", \"Nice to meet you async!\"],\n target=\"query\",\n )\n\n print(response.vectors[0][:10])\n print(response.vectors[1][:10])\n\n\nasyncio.run(demo())\n```\n\n#### 2.8 Sync call for files\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\n\nresp = client.files.create(filepath=\"sample.txt\", purpose=\"retrieval\")\nprint(resp.file.file_id)\n\nresp = client.files.list(purpose=\"retrieval\")\nprint(resp.files[0].file_id)\n\nresp = client.files.retrieve(file_id=resp.files[0].file_id)\nprint(resp.file.bytes)\n\nresp = client.files.delete(file_id=resp.file.file_id)\nprint(resp.file_id)\n```\n\n#### 2.9 Async call for files\n\n```python\nimport asyncio\n\nfrom minimax_client import AsyncMiniMax\n\n\nasync def demo():\n client = AsyncMiniMax(api_key=\"<YOUR_API_KEY>\")\n\n resp = await client.files.create(filepath=\"sample.txt\", purpose=\"retrieval\")\n print(resp.file.file_id)\n\n resp = await client.files.list(purpose=\"retrieval\")\n print(resp.files[0].file_id)\n\n resp = await client.files.retrieve(file_id=resp.files[0].file_id)\n print(resp.file.bytes)\n\n resp = await client.files.delete(file_id=resp.file.file_id)\n print(resp.file_id)\n\nasyncio.run(demo())\n```\n\n#### 2.10 Sync call for files\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.fine_tuning.jobs.create(\n model=\"abab5.5s-chat-240123\", training_file=..., suffix=\"test\"\n)\nprint(resp.id)\nprint(resp.fine_tuned_model)\n\nresp = client.fine_tuning.jobs.list(limit=5)\nprint(resp.job_list[0])\n\nresp = client.model.list()\nprint(resp.model_list[0])\n\nresp = client.model.retrieve(model=\"ft:abab5.5s-chat-240123_XXXXXXXXXXXXX:test\")\nprint(resp.model.id)\n```\n\n#### 2.11 Sync call for assistants\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.assistants.create(model=\"abab5.5s-chat-240123\")\n\nclient.assistants.update(\n assistant_id=resp.id,\n model=\"abab5.5s-chat-240123\",\n name=\"test-assistant\",\n instructions=\"You are a helpful assistant.\",\n)\n\nclient.assistants.retrieve(assistant_id=resp.id)\n\nclient.assistants.list(limit=5)\n\nclient.assistants.delete(assistant_id=resp.id)\n```\n\n#### 2.12 Sync call for assistant files\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.files.create(filepath=\"sample.txt\", purpose=\"retrieval\")\n\nfile_id = resp.file.file_id\n\nresp = client.assistants.create(\n model=\"abab5.5s-chat-240123\",\n name=\"test-assistant\",\n instructions=\"You are a helpful assistant.\",\n description=\"test-assistant\",\n tools=[{\"type\": \"retrieval\"}],\n)\n\nassistant_id = resp.id\n\nresp = client.assistants.files.create(assistant_id=assistant_id, file_id=str(file_id))\n\nresp = client.assistants.files.retrieve(assistant_id=assistant_id, file_id=str(file_id))\n\nresp = client.assistants.files.list(assistant_id=assistant_id, limit=5, order=\"asc\")\n\nresp = client.assistants.files.delete(assistant_id=assistant_id, file_id=str(file_id))\n```\n\n#### 2.13 Sync call for assistant threads\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.threads.create(metadata={\"key\": \"value\"})\n\nresp = client.threads.retrieve(thread_id=resp.id)\n\nresp = client.threads.update(thread_id=resp.id, metadata={\"key\": \"value2\"})\n```\n\n#### 2.14 Sync call for assistant messages\n\n```python\nimport time\n\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.threads.create(metadata={\"key\": \"value\"})\n\nthread_id = resp.id\n\nresp = client.threads.messages.create(\n thread_id=thread_id, content=\"Hello\", role=\"user\", metadata={\"key\": \"value\"}\n)\n\nresp = client.threads.messages.retrieve(thread_id=thread_id, message_id=resp.id)\n\nresp = client.threads.messages.list(thread_id=thread_id, limit=5, order=\"asc\")\n```\n\n#### 2.15 Sync call for assistant runs and run steps\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.assistants.create(\n model=\"abab5.5-chat\",\n name=\"test-assistant\",\n instructions=\"You are a helpful assistant that can use tools to answer questions.\",\n tools=[\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_weather\",\n \"description\": \"get weather\",\n \"parameters\": {\n \"type\": \"object\",\n \"required\": [\"city\"],\n \"properties\": {\"city\": {\"type\": \"string\"}},\n },\n },\n },\n {\"type\": \"web_search\"},\n {\"type\": \"code_interpreter\"},\n ],\n)\n\nassistant_id = resp.id\n\nresp = client.assistants.retrieve(assistant_id=assistant_id)\n\nprint(resp.model_dump())\n\nresp = client.threads.create(metadata={\"key1\": \"value1\"})\n\nthread_id = resp.id\n\nclient.threads.messages.create(\n thread_id=thread_id,\n role=\"user\",\n content=\"In the science-fiction 'Three-Body Problem', what is the profession of Wang Miao?\",\n)\n\nresp = client.threads.runs.create(thread_id=thread_id, assistant_id=assistant_id)\n\nrun_id = resp.id\n\ntime.sleep(10)\n\nresp = client.threads.runs.retrieve(run_id=run_id, thread_id=thread_id)\n\nprint(resp.model_dump())\n\nresp = client.threads.runs.steps.list(thread_id=thread_id, run_id=run_id, limit=10)\n\nfor step in resp.data:\n resp = client.threads.runs.steps.retrieve(\n step_id=step.id, thread_id=thread_id, run_id=run_id\n )\n\n print(resp.model_dump())\n```\n\n#### 2.16 Sync call for assistant STREAMED runs and run steps\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.assistants.create(\n model=\"abab5.5-chat\",\n name=\"test-assistant\",\n instructions=\"You are a helpful assistant.\",\n)\n\nassistant_id = resp.id\n\nresp = client.threads.create(metadata={\"key1\": \"value1\"})\n\nthread_id = resp.id\n\nfor part in client.threads.runs.stream(\n stream_mode=1,\n thread_id=thread_id,\n assistant_id=assistant_id,\n messages=[{\"type\": 1, \"role\": \"user\", \"content\": \"1 + 1 equals:\"}],\n):\n print(part.data.model_dump())\n print(\"\\n-----\\n\")\n```\n\n#### 2.17 Sync T2A\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.audio.speech(\n text=\"One apple a day keeps the doctor away\",\n model=\"speech-02\",\n timber_weights=[\n {\n \"voice_id\": \"male-qn-qingse\",\n \"weight\": 1,\n },\n {\n \"voice_id\": \"presenter_female\",\n \"weight\": 1,\n },\n ],\n vol=1,\n pitch=2,\n)\n\nif isinstance(resp, bytes):\n with open(\"speech.mp3\", \"wb\") as f:\n f.write(resp)\nelse:\n print(resp.model_dump())\n```\n\n#### 2.18 Sync Voice Cloning\n\n```python\nfrom minimax_client import MiniMax\n\n\nclient = MiniMax(api_key=\"<YOUR_API_KEY>\")\n\nresp = client.files.create(filepath=\"original_voice.mp3\", purpose=\"voice_clone\")\n\nfile_id = resp.file.file_id\n\nresp = client.audio.voice_cloning(\n file_id=file_id,\n voice_id=\"cloned12345678\",\n)\n\nprint(resp.model_dump())\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An (unofficial) python native client for easy interaction with MiniMax Open Platform",
"version": "0.6.2",
"project_urls": {
"Homepage": "https://pypi.org/project/minimax-client/",
"Repository": "https://github.com/linzeyang/minimax-python-client"
},
"split_keywords": [
"web",
" ai",
" api",
" llm",
" nlp",
" minimax"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e1861137adcb09fe1b1ace9dadaf608e3524b9c67ee2cd92288b7a4831c2895d",
"md5": "67416fb89bb3a1b49e85efa19ebce90a",
"sha256": "b927b621d6927a5d17ab2f9a37281c1e6a932cf2ebbf327232584a43190f2808"
},
"downloads": -1,
"filename": "minimax_client-0.6.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "67416fb89bb3a1b49e85efa19ebce90a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 29149,
"upload_time": "2024-10-11T07:44:59",
"upload_time_iso_8601": "2024-10-11T07:44:59.794450Z",
"url": "https://files.pythonhosted.org/packages/e1/86/1137adcb09fe1b1ace9dadaf608e3524b9c67ee2cd92288b7a4831c2895d/minimax_client-0.6.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae1d61ae821b16460795efe8d7e1daad6914d0da9ca96ddef2e5c0d12848ec8f",
"md5": "3a96bf31da8e3e3d0faa2f9c6e45a212",
"sha256": "eb4de8a18ecedf5e7f76a95aaf19fa2143754ebbdfbbac7893e480421424842e"
},
"downloads": -1,
"filename": "minimax_client-0.6.2.tar.gz",
"has_sig": false,
"md5_digest": "3a96bf31da8e3e3d0faa2f9c6e45a212",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 25188,
"upload_time": "2024-10-11T07:45:00",
"upload_time_iso_8601": "2024-10-11T07:45:00.977374Z",
"url": "https://files.pythonhosted.org/packages/ae/1d/61ae821b16460795efe8d7e1daad6914d0da9ca96ddef2e5c0d12848ec8f/minimax_client-0.6.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 07:45:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "linzeyang",
"github_project": "minimax-python-client",
"github_not_found": true,
"lcname": "minimax-client"
}