模型列表

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); // 文件存储 ID,可用于后续列表/删除

列表 / 删除

const list = await client.files.list();
await client.files.delete("file-xxxxxxxx");

HTTP 细节:文件

在对话中引用

SDK 的 client.chat.messages 内置文件处理,自动将本地路径转为 input_file + file_data(内联 base64):

const { content, plugins } = await client.chat.messages({
  prompt: "总结 PDF 要点",
  pdfPath: "/path/to/doc.pdf",
});

详见 文件与上下文 · SDK 概览

未实现

client.embeddings 会抛出 NotImplementedByGatewayError — 请用 HTTP Embeddings