API 密钥

API 密钥需要在控制台中创建和管理。

1. 登录 momolens → 进入设置 → momo soul 控制台
2. 点击侧边栏「API Keys」
3. 创建新的 API Key 并保存

前往创建 API Key

连接配置

Base URL
https://api.momolens.top/v1
API Key
sk-xxxxx(在控制台创建)
模型
momo-soul
认证方式
Bearer Token

API 文档

请求格式

发送 POST 请求到以下端点:

POST https://api.momolens.top/v1/chat/completions

请求头

Content-Type: application/json Authorization: Bearer sk-your-api-key

请求体

{ "model": "momo-soul", "messages": [ {"role": "user", "content": "你好"} ] }

响应格式

请求会返回 202 状态码和一个 request_id,你需要轮询获取结果:

// 第1步:发送请求 POST /v1/chat/completions // 返回: { "id": "550e8400-e29b-41d4-a716-446655440000", "status": "pending", "message": "Request queued. Poll GET /v1/chat/completions/{id} for response." } // 第2步:轮询获取结果 GET /v1/chat/completions/{request_id} // 当 status=completed 时返回完整响应: { "id": "chatcmpl-xxx", "object": "chat.completion", "choices": [{ "message": { "role": "assistant", "content": "你好!有什么可以帮你的吗?" } }] }

调用示例

Python

import openai import time client = openai.OpenAI( base_url="https://api.momolens.top/v1", api_key="sk-your-api-key" ) # 发送请求 resp = client.chat.completions.create( model="momo-soul", messages=[{"role": "user", "content": "你好"}] ) request_id = resp.id # 轮询获取结果 while True: result = client.get(f"/chat/completions/{request_id}") if result.status == "completed": print(result.choices[0].message.content) break time.sleep(1)

curl

# 第1步:发送请求 curl https://api.momolens.top/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-your-api-key" \ -d '{ "model": "momo-soul", "messages": [{"role": "user", "content": "你好"}] }' # 返回: {"id":"xxx","status":"pending"} # 第2步:轮询获取结果 curl https://api.momolens.top/v1/chat/completions/"请求ID" \ -H "Authorization: Bearer sk-your-api-key"

兼容客户端

客户端 Base URL 状态
OpenCode https://api.momolens.top/v1 兼容
ChatBox https://api.momolens.top/v1 兼容
NextWeb https://api.momolens.top/v1 兼容
Python openai https://api.momolens.top/v1 兼容