Skip to content

Commit 81cd271

Browse files
authored
js: infer gpt-5 on init (#1206)
depends on langchain-ai/langchainjs#9294
1 parent fc754d8 commit 81cd271

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/oss/javascript/migrate/langchain-v1.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ In v1, messages gain provider-agnostic standard content blocks. Access them via
539539
```typescript v1 (new)
540540
import { initChatModel } from "langchain";
541541

542-
const model = await initChatModel("openai:gpt-5-nano");
542+
const model = await initChatModel("gpt-5-nano");
543543
const response = await model.invoke("Explain AI");
544544

545545
for (const block of response.contentBlocks) {
@@ -623,7 +623,7 @@ export LC_OUTPUT_VERSION=v1
623623
```typescript
624624
import { initChatModel } from "langchain";
625625

626-
const model = await initChatModel("openai:gpt-5-nano", {
626+
const model = await initChatModel("gpt-5-nano", {
627627
outputVersion: "v1",
628628
});
629629
```

src/oss/langchain/agents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ agent = create_agent(
8585
import { createAgent } from "langchain";
8686

8787
const agent = createAgent({
88-
model: "openai:gpt-5",
88+
model: "gpt-5",
8989
tools: []
9090
});
9191
```

src/oss/langchain/messages.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ response = model.invoke(messages) # Returns AIMessage
4040
```typescript
4141
import { initChatModel, HumanMessage, SystemMessage } from "langchain";
4242

43-
const model = await initChatModel("openai:gpt-5-nano");
43+
const model = await initChatModel("gpt-5-nano");
4444

4545
const systemMsg = new SystemMessage("You are a helpful assistant.");
4646
const humanMsg = new HumanMessage("Hello, how are you?");
@@ -441,7 +441,7 @@ response.usage_metadata
441441
```typescript
442442
import { initChatModel } from "langchain";
443443

444-
const model = await initChatModel("openai:gpt-5-nano");
444+
const model = await initChatModel("gpt-5-nano");
445445

446446
const response = await model.invoke("Hello!");
447447
console.log(response.usage_metadata);
@@ -833,7 +833,7 @@ inference provider of your choice.
833833
import { initChatModel } from "langchain";
834834

835835
const model = await initChatModel(
836-
"openai:gpt-5-nano",
836+
"gpt-5-nano",
837837
{ outputVersion: "v1" }
838838
);
839839
```

src/oss/langchain/rag.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const retrieve = tool(
170170
}
171171
);
172172

173-
const agent = createAgent({ model: "openai:gpt-5", tools: [retrieve] });
173+
const agent = createAgent({ model: "gpt-5", tools: [retrieve] });
174174
```
175175
```typescript
176176
let inputMessage = `What is Task Decomposition?`;
@@ -572,7 +572,7 @@ const systemPrompt = new SystemMessage(
572572
"Use the tool to help answer user queries."
573573
)
574574

575-
const agent = createAgent({ model: "openai:gpt-5", tools, systemPrompt });
575+
const agent = createAgent({ model: "gpt-5", tools, systemPrompt });
576576
```
577577
:::
578578

src/oss/langchain/short-term-memory.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const stateExtensionMiddleware = createMiddleware({
160160

161161
const checkpointer = new MemorySaver();
162162
const agent = createAgent({
163-
model: "openai:gpt-5",
163+
model: "gpt-5",
164164
tools: [],
165165
middleware: [stateExtensionMiddleware] as const, // [!code highlight]
166166
checkpointer,
@@ -290,7 +290,7 @@ const stateModifier = async (state: AgentState) => {
290290

291291
const checkpointer = new MemorySaver();
292292
const agent = createAgent({
293-
model: "openai:gpt-5",
293+
model: "gpt-5",
294294
tools: [],
295295
preModelHook: stateModifier,
296296
checkpointer,
@@ -437,7 +437,7 @@ const deleteMessages = (state: AgentState) => {
437437
};
438438

439439
const agent = createAgent({
440-
model: "openai:gpt-5-nano",
440+
model: "gpt-5-nano",
441441
tools: [],
442442
prompt: "Please be concise and to the point.",
443443
postModelHook: deleteMessages,
@@ -631,7 +631,7 @@ const getUserInfo = tool(
631631
);
632632

633633
const agent = createAgent({
634-
model: "openai:gpt-5-nano",
634+
model: "gpt-5-nano",
635635
tools: [getUserInfo],
636636
stateSchema,
637637
});
@@ -860,7 +860,7 @@ const getWeather = tool(
860860
);
861861

862862
const agent = createAgent({
863-
model: "openai:gpt-5-nano",
863+
model: "gpt-5-nano",
864864
tools: [getWeather],
865865
contextSchema,
866866
prompt: (state, config) => {
@@ -1021,7 +1021,7 @@ const trimMessageHistory = createMiddleware({
10211021
});
10221022
10231023
const agent = createAgent({
1024-
model: "openai:gpt-5-nano",
1024+
model: "gpt-5-nano",
10251025
tools: [],
10261026
middleware: [trimMessageHistory],
10271027
});
@@ -1104,7 +1104,7 @@ const validateResponse = createMiddleware({
11041104
});
11051105
11061106
const agent = createAgent({
1107-
model: "openai:gpt-5-nano",
1107+
model: "gpt-5-nano",
11081108
tools: [],
11091109
middleware: [validateResponse],
11101110
});

src/oss/langchain/sql-agent.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ Now, create an agent with the model, tools, and prompt:
642642
import { createAgent } from "langchain";
643643

644644
const agent = createAgent({
645-
model: "openai:gpt-5",
645+
model: "gpt-5",
646646
tools: [executeSql],
647647
systemPrompt: getSystemPrompt,
648648
});
@@ -803,7 +803,7 @@ Rules:
803803
`);
804804

805805
export const agent = createAgent({
806-
model: "openai:gpt-5",
806+
model: "gpt-5",
807807
tools: [executeSql],
808808
systemPrompt: getSystemPrompt,
809809
});

src/oss/langchain/streaming.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const getWeather = tool(
9090
);
9191
9292
const agent = createAgent({
93-
model: "openai:gpt-5-nano",
93+
model: "gpt-5-nano",
9494
tools: [getWeather],
9595
});
9696

src/oss/langchain/structured-output.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ LangChain automatically uses `ProviderStrategy` when you pass a schema type dire
226226
});
227227
228228
const agent = createAgent({
229-
model: "openai:gpt-5",
229+
model: "gpt-5",
230230
tools: tools,
231231
responseFormat: providerStrategy(ContactInfo)
232232
});
@@ -254,7 +254,7 @@ LangChain automatically uses `ProviderStrategy` when you pass a schema type dire
254254
}
255255
256256
const agent = createAgent({
257-
model: "openai:gpt-5",
257+
model: "gpt-5",
258258
tools: tools,
259259
responseFormat: providerStrategy(contactInfoSchema)
260260
});
@@ -581,7 +581,7 @@ function toolStrategy<StructuredResponseT>(
581581
});
582582

583583
const agent = createAgent({
584-
model: "openai:gpt-5",
584+
model: "gpt-5",
585585
tools: tools,
586586
responseFormat: toolStrategy(ProductReview)
587587
})
@@ -622,7 +622,7 @@ function toolStrategy<StructuredResponseT>(
622622
}
623623

624624
const agent = createAgent({
625-
model: "openai:gpt-5",
625+
model: "gpt-5",
626626
tools: tools,
627627
responseFormat: toolStrategy(productReviewSchema)
628628
});
@@ -652,7 +652,7 @@ function toolStrategy<StructuredResponseT>(
652652
});
653653

654654
const agent = createAgent({
655-
model: "openai:gpt-5",
655+
model: "gpt-5",
656656
tools: tools,
657657
responseFormat: toolStrategy([ProductReview, CustomerComplaint])
658658
});
@@ -681,7 +681,7 @@ const MeetingAction = z.object({
681681
});
682682

683683
const agent = createAgent({
684-
model: "openai:gpt-5",
684+
model: "gpt-5",
685685
tools: [],
686686
responseFormat: toolStrategy(MeetingAction, {
687687
toolMessageContent: "Action item captured and added to meeting notes!"
@@ -812,7 +812,7 @@ const EventDetails = z.object({
812812
});
813813

814814
const agent = createAgent({
815-
model: "openai:gpt-5",
815+
model: "gpt-5",
816816
tools: [],
817817
responseFormat: toolStrategy([ContactInfo, EventDetails]),
818818
});
@@ -1002,7 +1002,7 @@ const ProductRating = z.object({
10021002
});
10031003

10041004
const agent = createAgent({
1005-
model: "openai:gpt-5",
1005+
model: "gpt-5",
10061006
tools: [],
10071007
responseFormat: toolStrategy(ProductRating),
10081008
});

0 commit comments

Comments
 (0)