
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
统一的多模型 AI SDK,面向研学 AI、DeepSeek,以及未来更多 LLM 扩展。
openx-ai 是一个统一的多模型大模型(LLM)调用层,支持:
目标: 让业务侧无论调用哪种模型,都使用 统一的调用代码。
parseStreamChunk,兼容 <CHECK_ERROR> 安全检查拦截npm install openx-ai --save
import OpenxAI from 'openx-ai'
const client = new OpenxAI({
appId: 'xxx', // 研学应用 appId
model: 'xai', // xai | deepseek | 更多模型
apiKey: '', // 第三方模型的 apiKey
env: 'development', // development | test | production
baseURL: 'https://xxx.cnki.net',
proxy: {}, // openx-js-sdk 的 proxy 配置
timeoutOptions:{
requestTimeoutMs: 60_000, // 请求超时时间,默认60s
idleTimeoutMs: 30_000, // 流式空闲超时,默认30s
}
})
const res = await client.chat.completions.create({
messages: [
{ role: 'user', content: '介绍一下你自己' }
],
stream: true,
source: 'xxx', // 研学 AI source
moduleVersionStr: 'xxx' // 研学 AI 模型版本
})
console.log(res)
所有模型都支持同一套流式接口:
const stream = await client.chat.completions.create({
messages: [{ role: 'user', content: '写一段诗' }],
stream: true
})
for await (const chunk of stream) {
if (chunk === '[DONE]') break
console.log(chunk)
}
client.abort()
在任何 stream 处理中均可调用。
try {
const stream = await client.chat.completions.create({ messages, stream: true })
for await (const chunk of stream) {
console.log(chunk)
}
} catch (err) {
console.error("连接未建立,已通过 try/catch 捕获异常:", err)
}
openx-ai 完全整合 openx-js-sdk,实现自动登录状态管理。
| 状态码 | 含义 | SDK 行为说明 |
|---|---|---|
| 5013 | JWT 过期 | 自动刷新 JWT → 自动重试一次 |
| 5014 | 刷新失败 | 清除 JWT → 输出“请重新登录” |
| 401 | 未授权 | 统一错误 → 停止流 |
SDK 保证:
先输出模型已经返回的部分内容 再输出错误信息
示例输出:
服务器错误,请稍后重试!
{"code":500, "message":"服务器错误"}
[DONE]
<CHECK_ERROR> 自动替换如果模型输出:
<CHECK_ERROR>
SDK 自动转换为安全内容:
作为AI语言模型,我的目标是以积极、正向和安全的方式提供帮助和信息,您的问题超出了我的回答范围。
[DONE]
你好
我是
模型
[DONE]
| 字段 | 类型 | 说明 |
|---|---|---|
| appId | string | 研学应用 AppId(必填) |
| model | string | xai, deepseek, qwen... |
| env | 'development' | 'test' |
| baseURL | string | 请求基础地址 |
| proxy | object | openx-js-sdk 的 proxy 配置 |
| apiKey | string | 三方模型 apiKey |
import OpenxAI from 'openx-ai'
let xai: OpenxAI | null = null
xai = new OpenxAI({
appId: 'CRSP_PSMC_RELEASE',
env: 'development',
baseURL: 'http://192.168.32.46:1009/proxy-ai/ai/aiCommon/multiChat',
model: 'xai',
proxy: {
'/proxy-sdk-jwt': {
open: false,
ws: false,
target: 'https://xtest.cnki.net/coreapi/api',
changeOrigin: true,
pathRewrite: { '^/proxy-sdk-jwt': '/' },
headers: {
origin: 'https://x.cnki.net',
referer: 'https://x.cnki.net'
}
},
'/proxy-sdk-ip': {
open: false,
ws: false,
target: 'https://xtest.cnki.net/ip',
changeOrigin: true,
pathRewrite: { '^/proxy-sdk-ip': '/' },
headers: {
origin: 'https://x.cnki.net',
referer: 'https://x.cnki.net'
}
}
}
})
document.querySelector('#start')?.addEventListener('click', async () => {
const completion = await xai!.chat.completions.create({
messages: [
{ role: 'system', content: '你是一个友好的AI助手。' },
{ role: 'user', content: '你好啊' }
],
source: 'xaiFullLibraryQA',
moduleVersionStr: 'tencent_deepseek_v3',
stream: true
})
try {
for await (const chunk of completion) {
console.log(chunk)
}
} catch (err) {
console.error('🔴 其他流错误:', err)
}
})
document.querySelector('#stop')?.addEventListener('click', () => {
xai?.abort()
console.log('🛑 已停止流')
})
FAQs
统一的多模型 AI SDK,面向研学 AI、DeepSeek,以及未来更多 LLM 扩展。
We found that openx-ai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.