模型列表
const res = await client.models.list();
for (const m of res.data) {
console.log(m.id, m.name);
}
等价于 GET https://51kik.com/v1/models。支持筛选参数(与 HTTP 查询参数一致):
await client.models.list({
q: "claude",
limit: 20,
offset: 0,
});
详见 模型列表。
文件上传
import { readFile } from "node:fs/promises";
const buf = await readFile("./spec.pdf");
const file = await client.files.upload({
file: buf,
filename: "spec.pdf",
purpose: "assistants",
});
console.log(file.id); // 用于 chat input_file.file_id
列表 / 删除
const list = await client.files.list();
await client.files.delete("file-xxxxxxxx");
HTTP 细节:文件。
在对话中引用
上传后把 file.id 写入 messages 的 input_file part,见 文件与上下文。
未实现
client.embeddings 会抛出 NotImplementedByGatewayError — 请用 HTTP Embeddings。