快速上手
5 分钟内开始使用 ModelMax。你将发送你的第一个对话补全请求并使用流式响应。
1. 获取 API 密钥
使用 Google 账号登录 ModelMax 控制台,然后在 设置 → API 密钥 中创建一个 API 密钥。
2. 发送对话补全请求
curl -X POST https://api.modelmax.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MODELMAX_API_KEY" \
-d '{
"model": "gemini-3-flash-preview",
"messages": [
{ "role": "user", "content": "用一句话解释量子计算。" }
]
}'
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.modelmax.io/v1",
)
response = client.chat.completions.create(
model="gemini-3-flash-preview",
messages=[
{"role": "user", "content": "用一句话解释量子计算。"}
],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-api-key",
baseURL: "https://api.modelmax.io/v1",
});
const response = await client.chat.completions.create({
model: "gemini-3-flash-preview",
messages: [
{ role: "user", content: "用一句话解释量子计算。" },
],
});
console.log(response.choices[0].message.content);
3. 流式响应
添加 "stream": true 以通过 Server-Sent Events 逐步接收生成的 token。
curl -X POST https://api.modelmax.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MODELMAX_API_KEY" \
-d '{
"model": "gemini-3-flash-preview",
"messages": [
{ "role": "user", "content": "写一首关于 API 的俳句。" }
],
"stream": true
}'
stream = client.chat.completions.create(
model="gemini-3-flash-preview",
messages=[{"role": "user", "content": "写一首关于 API 的俳句。"}],
stream=True,
)
for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)
const stream = await client.chat.completions.create({
model: "gemini-3-flash-preview",
messages: [{ role: "user", content: "写一首关于 API 的俳句。" }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}
4. 生成视频
视频生成使用异步队列 API。提交任务,轮询状态,然后下载结果。
# 提交
curl -X POST https://api.modelmax.io/v1/queue/veo-3 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MODELMAX_API_KEY" \
-d '{ "prompt": "A cat riding a skateboard through a neon-lit city" }'
# 响应 → { "request_id": "...", "status_url": "...", "response_url": "..." }
# 轮询状态
curl https://api.modelmax.io/v1/queue/veo-3/requests/{request_id}/status \
-H "Authorization: Bearer $MODELMAX_API_KEY"
# 当状态为 COMPLETED 时,获取结果
curl https://api.modelmax.io/v1/queue/veo-3/requests/{request_id} \
-H "Authorization: Bearer $MODELMAX_API_KEY"
查看完整的视频生成指南了解完整工作流。
