Python
import json
import os
from urllib.request import Request, urlopen
payload = {
"model": "MiniMax-M4",
"messages": [{"role": "user", "content": "In one sentence, explain why Array.sort() sorts [2, 10] as [10, 2] in JavaScript."}],
"reasoning_effort": "medium",
"max_tokens": 2048,
}
request = Request(
"https://direct.evolink.ai/v1/chat/completions",
data=json.dumps(payload).encode(),
headers={
"Authorization": "Bearer " + os.environ["EVOLINK_API_KEY"],
"Content-Type": "application/json",
},
)
with urlopen(request, timeout=120) as response:
print(json.load(response)["choices"][0]["message"]["content"])
JavaScript (Node.js)
// Run as a .mjs file with Node.js 18 or later.
const response = await fetch("https://direct.evolink.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.EVOLINK_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "MiniMax-M4",
messages: [{ role: "user", content: "In one sentence, explain why Array.sort() sorts [2, 10] as [10, 2] in JavaScript." }],
reasoning_effort: "medium",
max_tokens: 2048,
}),
})
if (!response.ok) throw new Error(await response.text())
const data = await response.json()
console.log(data.choices[0].message.content)