mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2025-10-14 22:34:40 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b2ae0554ee | ||
![]() |
399de41b61 | ||
![]() |
44316372a5 | ||
![]() |
fcc2c9f795 | ||
![]() |
a626a78553 | ||
![]() |
5f2eb803aa | ||
![]() |
684aedae1c | ||
![]() |
984d724367 | ||
![]() |
889c874264 |
21
README.md
21
README.md
@@ -11,11 +11,11 @@
|
||||

|
||||

|
||||
|
||||
支持高速流式输出、支持多轮对话、支持联网搜索、支持长文档解读、支持图像解析,零配置部署,多路token支持,自动清理会话痕迹。
|
||||
支持高速流式输出、支持多轮对话、支持联网搜索、支持智能体对话、支持长文档解读、支持图像OCR,零配置部署,多路token支持,自动清理会话痕迹。
|
||||
|
||||
与ChatGPT接口完全兼容。
|
||||
|
||||
还有以下六个free-api欢迎关注:
|
||||
还有以下八个free-api欢迎关注:
|
||||
|
||||
阶跃星辰 (跃问StepChat) 接口转API [step-free-api](https://github.com/LLM-Red-Team/step-free-api)
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
讯飞星火(Spark)接口转API [spark-free-api](https://github.com/LLM-Red-Team/spark-free-api)
|
||||
|
||||
MiniMax(海螺AI)接口转API [hailuo-free-api](https://github.com/LLM-Red-Team/hailuo-free-api)
|
||||
|
||||
深度求索(DeepSeek)接口转API [deepseek-free-api](https://github.com/LLM-Red-Team/deepseek-free-api)
|
||||
|
||||
聆心智能 (Emohaa) 接口转API [emohaa-free-api](https://github.com/LLM-Red-Team/emohaa-free-api)
|
||||
|
||||
## 目录
|
||||
@@ -85,11 +89,17 @@ https://udify.app/chat/Po0F6BMJ15q5vu2P
|
||||
|
||||

|
||||
|
||||
### 智能体对话Demo
|
||||
|
||||
此处使用 [翻译通](https://kimi.moonshot.cn/chat/coo6l3pkqq4ri39f36bg) 智能体。
|
||||
|
||||

|
||||
|
||||
### 长文档解读Demo
|
||||
|
||||

|
||||
|
||||
### 图像解析Demo
|
||||
### 图像OCR Demo
|
||||
|
||||

|
||||
|
||||
@@ -269,7 +279,8 @@ Authorization: Bearer [refresh_token]
|
||||
请求数据:
|
||||
```json
|
||||
{
|
||||
// 模型名称随意填写,如果不希望输出检索过程模型名称请包含silent_search
|
||||
// model随意填写,如果不希望输出检索过程模型名称请包含silent_search
|
||||
// 如果使用kimi+智能体,model请填写智能体ID,就是浏览器地址栏上尾部的一串英文+数字20个字符的ID
|
||||
"model": "kimi",
|
||||
// 目前多轮对话基于消息合并实现,某些场景可能导致能力下降且受单轮最大Token数限制
|
||||
// 如果您想获得原生的多轮对话体验,可以传入首轮消息获得的id,来接续上下文,注意如果使用这个,首轮必须传none,否则第二轮会空响应!
|
||||
@@ -377,7 +388,7 @@ Authorization: Bearer [refresh_token]
|
||||
}
|
||||
```
|
||||
|
||||
### 图像解析
|
||||
### 图像OCR
|
||||
|
||||
提供一个可访问的图像URL或者BASE64_URL进行解析。
|
||||
|
||||
|
BIN
doc/example-7.png
Normal file
BIN
doc/example-7.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kimi-free-api",
|
||||
"version": "0.0.32",
|
||||
"version": "0.0.34",
|
||||
"description": "Kimi Free API Server",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
@@ -137,6 +137,7 @@ async function getUserInfo(accessToken: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: 'https://kimi.moonshot.cn/',
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': `7${util.generateRandomString({ length: 18, charset: 'numeric' })}`,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -153,18 +154,21 @@ async function getUserInfo(accessToken: string, refreshToken: string) {
|
||||
*
|
||||
* @param refreshToken 用于刷新access_token的refresh_token
|
||||
*/
|
||||
async function createConversation(name: string, refreshToken: string) {
|
||||
async function createConversation(model: string, name: string, refreshToken: string) {
|
||||
const {
|
||||
accessToken,
|
||||
userId
|
||||
} = await acquireToken(refreshToken);
|
||||
const result = await axios.post('https://kimi.moonshot.cn/api/chat', {
|
||||
born_from: '',
|
||||
is_example: false,
|
||||
kimiplus_id: /^[0-9a-z]{20}$/.test(model) ? model : 'kimi',
|
||||
name
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: 'https://kimi.moonshot.cn/',
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -193,6 +197,7 @@ async function removeConversation(convId: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/chat/${convId}`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -221,6 +226,7 @@ async function promptSnippetSubmit(query: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: 'https://kimi.moonshot.cn/',
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -253,7 +259,7 @@ async function createCompletion(model = MODEL_NAME, messages: any[], refreshToke
|
||||
.catch(err => logger.error(err));
|
||||
|
||||
// 创建会话
|
||||
const convId = /[0-9a-zA-Z]{20}/.test(refConvId) ? refConvId : await createConversation("未命名会话", refreshToken);
|
||||
const convId = /[0-9a-zA-Z]{20}/.test(refConvId) ? refConvId : await createConversation(model, "未命名会话", refreshToken);
|
||||
|
||||
// 请求流
|
||||
const {
|
||||
@@ -262,14 +268,17 @@ async function createCompletion(model = MODEL_NAME, messages: any[], refreshToke
|
||||
} = await acquireToken(refreshToken);
|
||||
const sendMessages = messagesPrepare(messages, !!refConvId);
|
||||
const result = await axios.post(`https://kimi.moonshot.cn/api/chat/${convId}/completion/stream`, {
|
||||
kimiplus_id: /^[0-9a-z]{20}$/.test(model) ? model : 'kimi',
|
||||
messages: sendMessages,
|
||||
refs,
|
||||
is_pro_search: false,
|
||||
use_search: useSearch
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/chat/${convId}`,
|
||||
'Priority': 'u=1, i',
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -329,7 +338,7 @@ async function createCompletionStream(model = MODEL_NAME, messages: any[], refre
|
||||
.catch(err => logger.error(err));
|
||||
|
||||
// 创建会话
|
||||
const convId = /[0-9a-zA-Z]{20}/.test(refConvId) ? refConvId : await createConversation("未命名会话", refreshToken);
|
||||
const convId = /[0-9a-zA-Z]{20}/.test(refConvId) ? refConvId : await createConversation(model, "未命名会话", refreshToken);
|
||||
|
||||
// 请求流
|
||||
const {
|
||||
@@ -338,6 +347,7 @@ async function createCompletionStream(model = MODEL_NAME, messages: any[], refre
|
||||
} = await acquireToken(refreshToken);
|
||||
const sendMessages = messagesPrepare(messages, !!refConvId);
|
||||
const result = await axios.post(`https://kimi.moonshot.cn/api/chat/${convId}/completion/stream`, {
|
||||
kimiplus_id: /^[0-9a-z]{20}$/.test(model) ? model : undefined,
|
||||
messages: sendMessages,
|
||||
refs,
|
||||
use_search: useSearch
|
||||
@@ -348,6 +358,7 @@ async function createCompletionStream(model = MODEL_NAME, messages: any[], refre
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/chat/${convId}`,
|
||||
'Priority': 'u=1, i',
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -395,6 +406,7 @@ async function fakeRequest(refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
}
|
||||
@@ -537,6 +549,7 @@ async function preSignUrl(filename: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -622,6 +635,7 @@ async function uploadFile(fileUrl: string, refreshToken: string) {
|
||||
'Content-Type': mimeType,
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
},
|
||||
@@ -643,6 +657,7 @@ async function uploadFile(fileUrl: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
}
|
||||
@@ -664,6 +679,7 @@ async function uploadFile(fileUrl: string, refreshToken: string) {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Referer: `https://kimi.moonshot.cn/`,
|
||||
'X-Msh-Platform': 'web',
|
||||
'X-Traffic-Id': userId,
|
||||
...FAKE_HEADERS
|
||||
}
|
||||
|
Reference in New Issue
Block a user