Bug
client.skills.create({ files: [file] }) fails with 400 All files must be under a single top-level directory when the File name includes a directory path (e.g. my-skill/SKILL.md).
The OpenAI Skills API requires files to be under a top-level directory. However, the SDK's internal getName() function in internal/uploads.js strips directory paths:
function getName(value) {
return (((typeof value === 'object' && value !== null &&
(('name' in value && value.name && String(value.name)) || ...)) || '')
.split(/[\\/]/).pop() || undefined); // <-- strips directory
}
So new File([content], "my-skill/SKILL.md") becomes just SKILL.md in the multipart form.
Expected behavior
skills.create() should preserve directory paths in file names since the Skills API requires them. The Anthropic SDK handles this correctly by passing stripFilenames: false for skills.create.
Workaround
Build the FormData manually and use fetch directly:
const form = new FormData();
form.append("files", new Blob([content], { type: "text/markdown" }), "my-skill/SKILL.md");
const response = await fetch("https://api.openai.com/v1/skills", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}` },
body: form,
});
Environment
openai package version: 5.8.0 (also confirmed on earlier versions)
- Node.js 22
Bug
client.skills.create({ files: [file] })fails with400 All files must be under a single top-level directorywhen theFilename includes a directory path (e.g.my-skill/SKILL.md).The OpenAI Skills API requires files to be under a top-level directory. However, the SDK's internal
getName()function ininternal/uploads.jsstrips directory paths:So
new File([content], "my-skill/SKILL.md")becomes justSKILL.mdin the multipart form.Expected behavior
skills.create()should preserve directory paths in file names since the Skills API requires them. The Anthropic SDK handles this correctly by passingstripFilenames: falseforskills.create.Workaround
Build the
FormDatamanually and usefetchdirectly:Environment
openaipackage version: 5.8.0 (also confirmed on earlier versions)