Skip to content

skills.create: getName() strips directory paths from File names, breaking required directory structure #1807

@akhileshrangani4

Description

@akhileshrangani4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions