-
Notifications
You must be signed in to change notification settings - Fork 1.5k
skills.create: getName() strips directory paths from File names, breaking required directory structure #1807
Copy link
Copy link
Open
Description
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
openaipackage version: 5.8.0 (also confirmed on earlier versions)- Node.js 22
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels