Skip to content

Commit ad581c7

Browse files
Muhammad-Kamran-Khanchristian-bromannhntrl
authored
fix(openai): pass service_tier param to API when using useResponsesApi (#9898)
Co-authored-by: Christian Bromann <[email protected]> Co-authored-by: Hunter Lovell <[email protected]>
1 parent 4558fa6 commit ad581c7

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

.changeset/twelve-rivers-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@langchain/openai": patch
3+
---
4+
5+
fix(openai): pass service_tier to API when using Responses API

libs/providers/langchain-openai/src/chat_models/responses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class ChatOpenAIResponses<
8383
temperature: this.temperature,
8484
top_p: this.topP,
8585
user: this.user,
86+
service_tier: this.service_tier,
8687

8788
// if include_usage is set or streamUsage then stream must be set to true.
8889
stream: this.streaming,

libs/providers/langchain-openai/src/chat_models/tests/responses.int.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,3 +1241,14 @@ it("won't modify structured output content if outputVersion is set", async () =>
12411241
.invoke("respond with the name 'John'");
12421242
expect(response.name).toBeDefined();
12431243
});
1244+
1245+
test("ChatOpenAI with service_tier and useResponsesApi", async () => {
1246+
const model = new ChatOpenAI({
1247+
model: "gpt-4o",
1248+
useResponsesApi: true,
1249+
service_tier: "default",
1250+
apiKey: process.env.OPENAI_API_KEY || "sk-fake-key",
1251+
});
1252+
const res = await model.invoke("Hello");
1253+
expect(res.content).toBeDefined();
1254+
});

libs/providers/langchain-openai/src/chat_models/tests/responses.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ describe("strict tool-calling configuration", () => {
5151
expect((params.tools as Array<{ strict?: boolean }>)[0].strict).toBe(false);
5252
});
5353
});
54+
55+
describe("service_tier configuration", () => {
56+
it("passes service_tier to invocation params", () => {
57+
const model = new ChatOpenAIResponses({
58+
model: "gpt-4o",
59+
service_tier: "auto",
60+
});
61+
62+
const params = model.invocationParams({});
63+
expect(params.service_tier).toBe("auto");
64+
});
65+
});

0 commit comments

Comments
 (0)