Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,33 @@ describe("OpenAI Batch instrumentation", () => {
expect(received).toBe(content);
expect(await backgroundLogger.drain()).toEqual([]);
});

it("supports /v1/embeddings batch requests", async () => {
const embeddingsInput = [
{
custom_id: "emb1",
method: "POST",
url: "/v1/embeddings",
body: {
model: "text-embedding-3-small",
input: "hello world",
},
},
];

let received = "";
const result = await openaiFilesCreateTraced({
create(params: { file: Blob; purpose: string }) {
return asyncAPIPromise(
Promise.resolve({ id: "file_emb" }).then(async (file) => {
received = await params.file.text();
return file;
}),
);
},
})({ file: new Blob([jsonl(embeddingsInput)]), purpose: "batch" });

expect(result).toEqual({ id: "file_emb" });
expect(received).toBe(jsonl(embeddingsInput));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import {
processImagesInOutput,
} from "./openai-span-data";

const SUPPORTED_ENDPOINTS = new Set(["/v1/chat/completions", "/v1/responses"]);
const SUPPORTED_ENDPOINTS = new Set([
"/v1/chat/completions",
"/v1/responses",
"/v1/embeddings",
]);
const TERMINAL_STATUSES = new Set([
"completed",
"failed",
Expand Down