快速开始 · 3 分钟接入

快速开始

ModelFlow完全兼容 OpenAI SDK,只需修改 BaseURL 和 API Key,即可调用 40+ 主流大模型。

1

获取 API Key

登录控制台,进入“Key 管理”页面创建您的 API Key(格式 MF-xxx)。

2

复制 BaseURL

所有请求都指向 MG 的 OpenAI 兼容接口:https://mf.yunjii.cn/v1

3

发起第一次调用

使用您熟悉的语言,3 行代码即可调用 40+ 模型。

代码示例

选择您熟悉的语言,复制即可运行。

curl
curl -N https://mf.yunjii.cn/v1/chat/completions \
  -H "Authorization: Bearer MF-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "你好"}],
    "stream": true
  }'
python
from openai import OpenAI

client = OpenAI(
    base_url="https://mf.yunjii.cn/v1",
    api_key="MF-xxx"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "你好"}],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")
typescript
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://mf.yunjii.cn/v1',
  apiKey: process.env.MF_API_KEY,
})

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: '你好' }],
  stream: true,
})

for await (const chunk of response) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '')
}

验证成功

如果看到模型返回的流式文本,恭喜您——接入成功!接下来可以:

查看 API 参考 · 鉴权说明