Modelmesh normalizes requests and responses across service providers behind one consistent API.
Modelmesh provides an OpenAI-compatible Completion API for more than 300 models and service providers. Call it directly, through the OpenAI SDK, or with supported third-party SDKs.
Modelmesh-specific request headers in these examples are optional. When supplied, your application can appear on the Modelmesh rankings.
from openai import OpenAI
API_KEY = "$SSY_API_KEY"
client = OpenAI(
base_url="https://router.shengsuanyun.com/api/v1",
api_key=API_KEY,
)
try:
completion = client.chat.completions.create(
model="minimax/minimax-m2.7",
messages=[{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
temperature=0.6,
top_p=0.7,
stream=True,
)
response_text = ""
for chunk in completion:
if chunk.choices and chunk.choices[0].delta.content is not None:
content = chunk.choices[0].delta.content
print(content, end="", flush=True)
response_text += content
except Exception as error:
print(f"Request failed: {error}")
1
from openai import OpenAI
2
3
API_KEY = "$SSY_API_KEY"
4
5
client = OpenAI(
6
base_url="https://router.shengsuanyun.com/api/v1",
7
api_key=API_KEY,
8
)
9
10
try:
11
completion = client.chat.completions.create(
12
model="minimax/minimax-m2.7",
13
messages=[{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
14
temperature=0.6,
15
top_p=0.7,
16
stream=True,
17
)
18
19
response_text = ""
20
21
for chunk in completion:
22
if chunk.choices and chunk.choices[0].delta.content is not None:
23
content = chunk.choices[0].delta.content
24
print(content, end="", flush=True)
25
response_text += content
26
27
except Exception as error:
28
print(f"Request failed: {error}")
import OpenAI from "openai";
const apiKey = "$SSY_API_KEY";
const openai = new OpenAI({
baseURL: "https://router.shengsuanyun.com/api/v1",
apiKey,
});
async function main() {
try {
const stream = await openai.chat.completions.create({
model: "minimax/minimax-m2.7",
messages: [{ role: "user", content: "Which number is larger, 9.11 or 9.8?" }],
temperature: 0.6,
top_p: 0.7,
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}
console.log("\n[chat complete]");
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Request failed:", message);
process.exitCode = 1;
}
}
main();
1
import OpenAI from "openai";
2
3
const apiKey = "$SSY_API_KEY";
4
5
const openai = new OpenAI({
6
baseURL: "https://router.shengsuanyun.com/api/v1",
7
apiKey,
8
});
9
10
async function main() {
11
try {
12
const stream = await openai.chat.completions.create({
13
model: "minimax/minimax-m2.7",
14
messages: [{ role: "user", content: "Which number is larger, 9.11 or 9.8?" }],
15
temperature: 0.6,
16
top_p: 0.7,
17
stream: true,
18
});
19
20
for await (const chunk of stream) {
21
const content = chunk.choices[0]?.delta?.content;
22
if (content) process.stdout.write(content);
23
}
24
25
console.log("\n[chat complete]");
26
} catch (error) {
27
const message = error instanceof Error ? error.message : String(error);
28
console.error("Request failed:", message);
29
process.exitCode = 1;
30
}
31
}
32
33
main();
#!/usr/bin/env bash
set -euo pipefail
API_KEY="$SSY_API_KEY"
BASE_URL="https://router.shengsuanyun.com/api/v1/chat/completions"
MODEL='minimax/minimax-m2.7'
curl --fail-with-body --silent --show-error --no-buffer -X POST "${BASE_URL}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${API_KEY}" \
-d '{
"model": "'"${MODEL}"'",
"messages": [{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
"temperature": 0.6,
"top_p": 0.7,
"stream": true
}'
printf '\n[chat complete]\n'
1
2
set -euo pipefail
3
4
API_KEY="$SSY_API_KEY"
5
BASE_URL="https://router.shengsuanyun.com/api/v1/chat/completions"
6
MODEL='minimax/minimax-m2.7'
7
8
curl --fail-with-body --silent --show-error --no-buffer -X POST "${BASE_URL}" \
9
-H "Content-Type: application/json" \
10
-H "Authorization: Bearer ${API_KEY}" \
11
-d '{
12
"model": "'"${MODEL}"'",
13
"messages": [{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}],
14
"temperature": 0.6,
15
"top_p": 0.7,
16
"stream": true
17
}'
18
19
printf '\n[chat complete]\n'
import requests
API_KEY = "$SSY_API_KEY"
url = "https://router.shengsuanyun.com/api/v1/messages"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
payload = {
"model": "minimax/minimax-m2.7",
"messages": [{"role": "user", "content": "Hello"}],
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.json())
1
import requests
2
3
API_KEY = "$SSY_API_KEY"
4
url = "https://router.shengsuanyun.com/api/v1/messages"
5
headers = {
6
"Authorization": f"Bearer {API_KEY}",
7
"Content-Type": "application/json",
8
}
9
payload = {
10
"model": "minimax/minimax-m2.7",
11
"messages": [{"role": "user", "content": "Hello"}],
12
}
13
14
response = requests.post(url, headers=headers, json=payload, timeout=30)
15
response.raise_for_status()
16
print(response.json())
const apiKey = "$SSY_API_KEY";
async function main() {
const response = await fetch("https://router.shengsuanyun.com/api/v1/messages", {
method: "POST",
headers: {
Authorization: "Bearer " + apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "minimax/minimax-m2.7",
messages: [{ role: "user", content: "Hello" }],
}),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`Request failed with status ${response.status}: ${text}`);
}
console.log(await response.json());
}
main().catch((error) => {
const message = error instanceof Error ? error.message : String(error);
console.error("Request failed:", message);
});
1
const apiKey = "$SSY_API_KEY";
2
3
async function main() {
4
const response = await fetch("https://router.shengsuanyun.com/api/v1/messages", {
5
method: "POST",
6
headers: {
7
Authorization: "Bearer " + apiKey,
8
"Content-Type": "application/json",
9
},
10
body: JSON.stringify({
11
model: "minimax/minimax-m2.7",
12
messages: [{ role: "user", content: "Hello" }],
13
}),
14
});
15
16
if (!response.ok) {
17
const text = await response.text();
18
throw new Error(`Request failed with status ${response.status}: ${text}`);
19
}
20
21
console.log(await response.json());
22
}
23
24
main().catch((error) => {
25
const message = error instanceof Error ? error.message : String(error);
26
console.error("Request failed:", message);
27
});
#!/usr/bin/env bash
set -euo pipefail
API_KEY="$SSY_API_KEY"
BASE_URL="https://router.shengsuanyun.com/api/v1/messages"
MODEL='minimax/minimax-m2.7'
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${API_KEY}" \
-d '{
"model": "'"${MODEL}"'",
"messages": [{"role": "user", "content": "Hello"}]
}'
1
2
set -euo pipefail
3
4
API_KEY="$SSY_API_KEY"
5
BASE_URL="https://router.shengsuanyun.com/api/v1/messages"
6
MODEL='minimax/minimax-m2.7'
7
8
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
9
-H "Content-Type: application/json" \
10
-H "Authorization: Bearer ${API_KEY}" \
11
-d '{
12
"model": "'"${MODEL}"'",
13
"messages": [{"role": "user", "content": "Hello"}]
14
}'
from openai import OpenAI
API_KEY = "$SSY_API_KEY"
client = OpenAI(
base_url="https://router.shengsuanyun.com/api/v1",
api_key=API_KEY,
)
messages = [
{"role": "user", "content": "Describe Romance of the Three Kingdoms in 100 words."},
]
response = client.responses.create(
model="minimax/minimax-m2.7",
input=messages,
)
print(response.output_text)
1
from openai import OpenAI
2
3
API_KEY = "$SSY_API_KEY"
4
5
client = OpenAI(
6
base_url="https://router.shengsuanyun.com/api/v1",
7
api_key=API_KEY,
8
)
9
10
messages = [
11
{"role": "user", "content": "Describe Romance of the Three Kingdoms in 100 words."},
12
]
13
14
response = client.responses.create(
15
model="minimax/minimax-m2.7",
16
input=messages,
17
)
18
19
print(response.output_text)
import OpenAI from "openai";
const apiKey = "$SSY_API_KEY";
const client = new OpenAI({
baseURL: "https://router.shengsuanyun.com/api/v1",
apiKey,
});
async function main() {
const messages = [
{ role: "user", content: "Describe Romance of the Three Kingdoms in 100 words." },
];
const response = await client.responses.create({
model: "minimax/minimax-m2.7",
input: messages,
});
console.log(response.output_text);
}
main().catch((error) => {
const message = error instanceof Error ? error.message : String(error);
console.error("Request failed:", message);
});
1
import OpenAI from "openai";
2
3
const apiKey = "$SSY_API_KEY";
4
5
const client = new OpenAI({
6
baseURL: "https://router.shengsuanyun.com/api/v1",
7
apiKey,
8
});
9
10
async function main() {
11
const messages = [
12
{ role: "user", content: "Describe Romance of the Three Kingdoms in 100 words." },
13
];
14
15
const response = await client.responses.create({
16
model: "minimax/minimax-m2.7",
17
input: messages,
18
});
19
20
console.log(response.output_text);
21
}
22
23
main().catch((error) => {
24
const message = error instanceof Error ? error.message : String(error);
25
console.error("Request failed:", message);
26
});
#!/usr/bin/env bash
set -euo pipefail
API_KEY="$SSY_API_KEY"
MODEL='minimax/minimax-m2.7'
BASE_URL="https://router.shengsuanyun.com/api/v1/responses"
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${API_KEY}" \
-d '{
"model": "'"${MODEL}"'",
"input": [
{
"role": "user",
"content": "Describe Romance of the Three Kingdoms in 100 words."
}
]
}' | python3 -c 'import json,sys
data=json.load(sys.stdin)
text=data.get("output_text") or "".join(
part.get("text", "")
for item in data.get("output", [])
for part in item.get("content", [])
if part.get("type") == "output_text"
)
print(text)'
1
2
set -euo pipefail
3
4
API_KEY="$SSY_API_KEY"
5
MODEL='minimax/minimax-m2.7'
6
BASE_URL="https://router.shengsuanyun.com/api/v1/responses"
7
8
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
9
-H "Content-Type: application/json" \
10
-H "Authorization: Bearer ${API_KEY}" \
11
-d '{
12
"model": "'"${MODEL}"'",
13
"input": [
14
{
15
"role": "user",
16
"content": "Describe Romance of the Three Kingdoms in 100 words."
17
}
18
]
19
}' | python3 -c 'import json,sys
20
data=json.load(sys.stdin)
21
text=data.get("output_text") or "".join(
22
part.get("text", "")
23
for item in data.get("output", [])
24
for part in item.get("content", [])
25
if part.get("type") == "output_text"
26
)
27
print(text)'
import requests
API_KEY = "$SSY_API_KEY"
MODEL = "minimax/minimax-m2.7"
URL = f"https://router.shengsuanyun.com/api/v1beta/models/{MODEL}:generateContent"
messages = [
{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}
]
payload = {
"contents": [
{
"role": message["role"],
"parts": [{"text": message["content"]}],
}
for message in messages
],
"generationConfig": {
"temperature": 0.6,
"topP": 0.7,
"maxOutputTokens": 1024,
},
}
headers = {
"Content-Type": "application/json",
# This endpoint uses API-key auth, not Bearer auth.
"x-goog-api-key": API_KEY,
}
# Gemini-style generateContent uses contents, so messages are mapped into contents.
response = requests.post(URL, headers=headers, json=payload, timeout=30)
response.raise_for_status()
data = response.json()
candidates = data.get("candidates") or [{}]
parts = (candidates[0].get("content") or {}).get("parts") or []
print("".join(part.get("text", "") for part in parts))
1
import requests
2
3
API_KEY = "$SSY_API_KEY"
4
MODEL = "minimax/minimax-m2.7"
5
URL = f"https://router.shengsuanyun.com/api/v1beta/models/{MODEL}:generateContent"
6
messages = [
7
{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}
8
]
9
10
payload = {
11
"contents": [
12
{
13
"role": message["role"],
14
"parts": [{"text": message["content"]}],
15
}
16
for message in messages
17
],
18
"generationConfig": {
19
"temperature": 0.6,
20
"topP": 0.7,
21
"maxOutputTokens": 1024,
22
},
23
}
24
25
headers = {
26
"Content-Type": "application/json",
27
28
"x-goog-api-key": API_KEY,
29
}
30
31
32
response = requests.post(URL, headers=headers, json=payload, timeout=30)
33
response.raise_for_status()
34
data = response.json()
35
candidates = data.get("candidates") or [{}]
36
parts = (candidates[0].get("content") or {}).get("parts") or []
37
print("".join(part.get("text", "") for part in parts))
const API_KEY = "$SSY_API_KEY";
const MODEL = "minimax/minimax-m2.7";
const url = `https://router.shengsuanyun.com/api/v1beta/models/${MODEL}:generateContent`;
const messages = [
{ role: "user", content: "Which number is larger, 9.11 or 9.8?" },
];
async function main() {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": API_KEY,
},
body: JSON.stringify({
contents: messages.map((message) => ({
role: message.role,
parts: [{ text: message.content }],
})),
generationConfig: {
temperature: 0.6,
topP: 0.7,
maxOutputTokens: 1024,
},
}),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`Request failed with status ${response.status}: ${text}`);
}
const data = await response.json();
const text = (data.candidates?.[0]?.content?.parts ?? [])
.map((part) => part.text ?? "")
.join("");
console.log(text);
}
main().catch((error) => {
const message = error instanceof Error ? error.message : String(error);
console.error("Request failed:", message);
});
1
const API_KEY = "$SSY_API_KEY";
2
3
const MODEL = "minimax/minimax-m2.7";
4
const url = `https://router.shengsuanyun.com/api/v1beta/models/${MODEL}:generateContent`;
5
const messages = [
6
{ role: "user", content: "Which number is larger, 9.11 or 9.8?" },
7
];
8
9
async function main() {
10
const response = await fetch(url, {
11
method: "POST",
12
headers: {
13
"Content-Type": "application/json",
14
"x-goog-api-key": API_KEY,
15
},
16
body: JSON.stringify({
17
contents: messages.map((message) => ({
18
role: message.role,
19
parts: [{ text: message.content }],
20
})),
21
generationConfig: {
22
temperature: 0.6,
23
topP: 0.7,
24
maxOutputTokens: 1024,
25
},
26
}),
27
});
28
29
if (!response.ok) {
30
const text = await response.text();
31
throw new Error(`Request failed with status ${response.status}: ${text}`);
32
}
33
34
const data = await response.json();
35
const text = (data.candidates?.[0]?.content?.parts ?? [])
36
.map((part) => part.text ?? "")
37
.join("");
38
console.log(text);
39
}
40
41
main().catch((error) => {
42
const message = error instanceof Error ? error.message : String(error);
43
console.error("Request failed:", message);
44
});
#!/usr/bin/env bash
set -euo pipefail
API_KEY="$SSY_API_KEY"
MODEL='minimax/minimax-m2.7'
BASE_URL="https://router.shengsuanyun.com/api/v1beta/models/${MODEL}:generateContent"
# This endpoint uses API-key auth, not Bearer auth.
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: ${API_KEY}" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Which number is larger, 9.11 or 9.8?"}]
}
],
"generationConfig": {
"temperature": 0.6,
"topP": 0.7,
"maxOutputTokens": 1024
}
}' | python3 -c 'import json,sys
data=json.load(sys.stdin)
candidates=data.get("candidates") or [{}]
parts=(candidates[0].get("content") or {}).get("parts") or []
print("".join(part.get("text", "") for part in parts))'
1
2
set -euo pipefail
3
4
API_KEY="$SSY_API_KEY"
5
MODEL='minimax/minimax-m2.7'
6
BASE_URL="https://router.shengsuanyun.com/api/v1beta/models/${MODEL}:generateContent"
7
8
9
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
10
-H "Content-Type: application/json" \
11
-H "x-goog-api-key: ${API_KEY}" \
12
-d '{
13
"contents": [
14
{
15
"role": "user",
16
"parts": [{"text": "Which number is larger, 9.11 or 9.8?"}]
17
}
18
],
19
"generationConfig": {
20
"temperature": 0.6,
21
"topP": 0.7,
22
"maxOutputTokens": 1024
23
}
24
}' | python3 -c 'import json,sys
25
data=json.load(sys.stdin)
26
candidates=data.get("candidates") or [{}]
27
parts=(candidates[0].get("content") or {}).get("parts") or []
28
print("".join(part.get("text", "") for part in parts))'
import requests
API_KEY = "$SSY_API_KEY"
MODEL = "minimax/minimax-m2.7"
URL = f"https://router.shengsuanyun.com/api/v1/models/{MODEL}:generateContent"
messages = [
{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}
]
payload = {
"contents": [
{
"role": message["role"],
"parts": [{"text": message["content"]}],
}
for message in messages
],
"generationConfig": {
"temperature": 0.6,
"topP": 0.7,
"maxOutputTokens": 1024,
},
}
headers = {
"Content-Type": "application/json",
# This endpoint uses API-key auth, not Bearer auth.
"x-goog-api-key": API_KEY,
}
# Gemini-style generateContent uses contents, so messages are mapped into contents.
response = requests.post(URL, headers=headers, json=payload, timeout=30)
response.raise_for_status()
data = response.json()
candidates = data.get("candidates") or [{}]
parts = (candidates[0].get("content") or {}).get("parts") or []
print("".join(part.get("text", "") for part in parts))
1
import requests
2
3
API_KEY = "$SSY_API_KEY"
4
MODEL = "minimax/minimax-m2.7"
5
URL = f"https://router.shengsuanyun.com/api/v1/models/{MODEL}:generateContent"
6
messages = [
7
{"role": "user", "content": "Which number is larger, 9.11 or 9.8?"}
8
]
9
10
payload = {
11
"contents": [
12
{
13
"role": message["role"],
14
"parts": [{"text": message["content"]}],
15
}
16
for message in messages
17
],
18
"generationConfig": {
19
"temperature": 0.6,
20
"topP": 0.7,
21
"maxOutputTokens": 1024,
22
},
23
}
24
25
headers = {
26
"Content-Type": "application/json",
27
28
"x-goog-api-key": API_KEY,
29
}
30
31
32
response = requests.post(URL, headers=headers, json=payload, timeout=30)
33
response.raise_for_status()
34
data = response.json()
35
candidates = data.get("candidates") or [{}]
36
parts = (candidates[0].get("content") or {}).get("parts") or []
37
print("".join(part.get("text", "") for part in parts))
const API_KEY = "$SSY_API_KEY";
const MODEL = "minimax/minimax-m2.7";
const url = `https://router.shengsuanyun.com/api/v1/models/${MODEL}:generateContent`;
const messages = [
{ role: "user", content: "Which number is larger, 9.11 or 9.8?" },
];
async function main() {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": API_KEY,
},
body: JSON.stringify({
contents: messages.map((message) => ({
role: message.role,
parts: [{ text: message.content }],
})),
generationConfig: {
temperature: 0.6,
topP: 0.7,
maxOutputTokens: 1024,
},
}),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`Request failed with status ${response.status}: ${text}`);
}
const data = await response.json();
const text = (data.candidates?.[0]?.content?.parts ?? [])
.map((part) => part.text ?? "")
.join("");
console.log(text);
}
main().catch((error) => {
const message = error instanceof Error ? error.message : String(error);
console.error("Request failed:", message);
});
1
const API_KEY = "$SSY_API_KEY";
2
3
const MODEL = "minimax/minimax-m2.7";
4
const url = `https://router.shengsuanyun.com/api/v1/models/${MODEL}:generateContent`;
5
const messages = [
6
{ role: "user", content: "Which number is larger, 9.11 or 9.8?" },
7
];
8
9
async function main() {
10
const response = await fetch(url, {
11
method: "POST",
12
headers: {
13
"Content-Type": "application/json",
14
"x-goog-api-key": API_KEY,
15
},
16
body: JSON.stringify({
17
contents: messages.map((message) => ({
18
role: message.role,
19
parts: [{ text: message.content }],
20
})),
21
generationConfig: {
22
temperature: 0.6,
23
topP: 0.7,
24
maxOutputTokens: 1024,
25
},
26
}),
27
});
28
29
if (!response.ok) {
30
const text = await response.text();
31
throw new Error(`Request failed with status ${response.status}: ${text}`);
32
}
33
34
const data = await response.json();
35
const text = (data.candidates?.[0]?.content?.parts ?? [])
36
.map((part) => part.text ?? "")
37
.join("");
38
console.log(text);
39
}
40
41
main().catch((error) => {
42
const message = error instanceof Error ? error.message : String(error);
43
console.error("Request failed:", message);
44
});
#!/usr/bin/env bash
set -euo pipefail
API_KEY="$SSY_API_KEY"
MODEL='minimax/minimax-m2.7'
BASE_URL="https://router.shengsuanyun.com/api/v1/models/${MODEL}:generateContent"
# This endpoint uses API-key auth, not Bearer auth.
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: ${API_KEY}" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Which number is larger, 9.11 or 9.8?"}]
}
],
"generationConfig": {
"temperature": 0.6,
"topP": 0.7,
"maxOutputTokens": 1024
}
}' | python3 -c 'import json,sys
data=json.load(sys.stdin)
candidates=data.get("candidates") or [{}]
parts=(candidates[0].get("content") or {}).get("parts") or []
print("".join(part.get("text", "") for part in parts))'
1
2
set -euo pipefail
3
4
API_KEY="$SSY_API_KEY"
5
MODEL='minimax/minimax-m2.7'
6
BASE_URL="https://router.shengsuanyun.com/api/v1/models/${MODEL}:generateContent"
7
8
9
curl --fail-with-body --silent --show-error -X POST "${BASE_URL}" \
10
-H "Content-Type: application/json" \
11
-H "x-goog-api-key: ${API_KEY}" \
12
-d '{
13
"contents": [
14
{
15
"role": "user",
16
"parts": [{"text": "Which number is larger, 9.11 or 9.8?"}]
17
}
18
],
19
"generationConfig": {
20
"temperature": 0.6,
21
"topP": 0.7,
22
"maxOutputTokens": 1024
23
}
24
}' | python3 -c 'import json,sys
25
data=json.load(sys.stdin)
26
candidates=data.get("candidates") or [{}]
27
parts=(candidates[0].get("content") or {}).get("parts") or []
28
print("".join(part.get("text", "") for part in parts))'