Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/protocol/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ export function buildResponsesRequest(
// is a wire contract to depend on.
accept: quirks.stream ? "text/event-stream" : "application/json",
authorization: BEARER_CREDENTIAL_SENTINEL,
...quirks.headers.static,
};
for (const [name, value] of Object.entries(quirks.headers.static)) {
headers[name] = value;
}
if (quirks.headers.modelHeader !== undefined) {
headers[quirks.headers.modelHeader] = model;
}
Expand Down
12 changes: 12 additions & 0 deletions src/responses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ describe("Responses request builder — quirk matrix", () => {
expect(request.headers["accept"]).toBe(accept);
});

test("static headers override defaults and per-request headers override static ones", () => {
const adapter = createOpenAIResponsesAdapter(source, {
headers: {
static: { accept: "application/x-ndjson", "x-model": "static" },
modelHeader: "x-model",
},
});
const { headers } = adapter.buildRequest(turns, "m", {});
expect(headers["accept"]).toBe("application/x-ndjson");
expect(headers["x-model"]).toBe("m");
});

test("typed shape (the default) splits assistant text into output_text", () => {
const adapter = createOpenAIResponsesAdapter(source, {});
const assistantTurn: ConversationTurn[] = [
Expand Down
Loading