@copilotkit/runtime 1.71.0 → 1.71.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +22 -0
  2. package/dist/agent/index.cjs +15 -3
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +1 -0
  5. package/dist/agent/index.d.cts.map +1 -1
  6. package/dist/agent/index.d.mts +1 -0
  7. package/dist/agent/index.d.mts.map +1 -1
  8. package/dist/agent/index.mjs +15 -3
  9. package/dist/agent/index.mjs.map +1 -1
  10. package/dist/index.cjs +1 -0
  11. package/dist/index.d.cts +9 -1
  12. package/dist/index.d.mts +9 -1
  13. package/dist/index.mjs +2 -2
  14. package/dist/lib/telemetry-client.cjs.map +1 -1
  15. package/dist/lib/telemetry-client.mjs.map +1 -1
  16. package/dist/package.cjs +8 -6
  17. package/dist/package.mjs +8 -6
  18. package/dist/service-adapters/anthropic/anthropic-adapter.cjs +59 -25
  19. package/dist/service-adapters/anthropic/anthropic-adapter.cjs.map +1 -1
  20. package/dist/service-adapters/anthropic/anthropic-adapter.d.cts +30 -1
  21. package/dist/service-adapters/anthropic/anthropic-adapter.d.cts.map +1 -1
  22. package/dist/service-adapters/anthropic/anthropic-adapter.d.mts +30 -1
  23. package/dist/service-adapters/anthropic/anthropic-adapter.d.mts.map +1 -1
  24. package/dist/service-adapters/anthropic/anthropic-adapter.mjs +59 -26
  25. package/dist/service-adapters/anthropic/anthropic-adapter.mjs.map +1 -1
  26. package/dist/service-adapters/index.d.cts +1 -1
  27. package/dist/service-adapters/index.d.mts +1 -1
  28. package/dist/v2/index.cjs +2 -0
  29. package/dist/v2/index.d.cts +2 -1
  30. package/dist/v2/index.d.mts +2 -1
  31. package/dist/v2/index.mjs +2 -1
  32. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  33. package/dist/v2/runtime/core/runtime.d.cts +2 -1
  34. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  35. package/dist/v2/runtime/core/runtime.d.mts +2 -1
  36. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  37. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  38. package/dist/v2/runtime/handlers/handle-run.cjs +2 -1
  39. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  40. package/dist/v2/runtime/handlers/handle-run.mjs +2 -1
  41. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  42. package/dist/v2/runtime/handlers/handle-stop.cjs +41 -1
  43. package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -1
  44. package/dist/v2/runtime/handlers/handle-stop.mjs +42 -2
  45. package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -1
  46. package/dist/v2/runtime/handlers/intelligence/run.cjs +1 -1
  47. package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
  48. package/dist/v2/runtime/handlers/intelligence/run.mjs +1 -1
  49. package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
  50. package/dist/v2/runtime/handlers/intelligence/threads.cjs +2 -3
  51. package/dist/v2/runtime/handlers/intelligence/threads.cjs.map +1 -1
  52. package/dist/v2/runtime/handlers/intelligence/threads.mjs +2 -3
  53. package/dist/v2/runtime/handlers/intelligence/threads.mjs.map +1 -1
  54. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +8 -2
  55. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  56. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +8 -2
  57. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  58. package/dist/v2/runtime/index.d.cts +1 -0
  59. package/dist/v2/runtime/index.d.cts.map +1 -1
  60. package/dist/v2/runtime/index.d.mts +1 -0
  61. package/dist/v2/runtime/index.d.mts.map +1 -1
  62. package/dist/v2/runtime/intelligence-platform/client.cjs +106 -1
  63. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  64. package/dist/v2/runtime/intelligence-platform/client.d.cts +11 -0
  65. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  66. package/dist/v2/runtime/intelligence-platform/client.d.mts +11 -0
  67. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  68. package/dist/v2/runtime/intelligence-platform/client.mjs +106 -1
  69. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  70. package/dist/v2/runtime/intelligence-platform/index.d.cts +1 -0
  71. package/dist/v2/runtime/intelligence-platform/index.d.mts +1 -0
  72. package/dist/v2/runtime/intelligence-platform/learned-skills.cjs +43 -0
  73. package/dist/v2/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
  74. package/dist/v2/runtime/intelligence-platform/learned-skills.d.cts +34 -0
  75. package/dist/v2/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
  76. package/dist/v2/runtime/intelligence-platform/learned-skills.d.mts +34 -0
  77. package/dist/v2/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
  78. package/dist/v2/runtime/intelligence-platform/learned-skills.mjs +41 -0
  79. package/dist/v2/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
  80. package/dist/v2/runtime/runner/intelligence.cjs +82 -25
  81. package/dist/v2/runtime/runner/intelligence.cjs.map +1 -1
  82. package/dist/v2/runtime/runner/intelligence.d.cts +3 -0
  83. package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -1
  84. package/dist/v2/runtime/runner/intelligence.d.mts +3 -0
  85. package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -1
  86. package/dist/v2/runtime/runner/intelligence.mjs +83 -26
  87. package/dist/v2/runtime/runner/intelligence.mjs.map +1 -1
  88. package/package.json +10 -7
  89. package/skills/runtime/SKILL.md +0 -98
  90. package/skills/runtime/references/agent-runners-custom.md +0 -161
  91. package/skills/runtime/references/agent-runners-in-memory.md +0 -79
  92. package/skills/runtime/references/agent-runners-sqlite.md +0 -90
  93. package/skills/runtime/references/agent-runners.md +0 -336
  94. package/skills/runtime/references/built-in-agent-factory-modes.md +0 -232
  95. package/skills/runtime/references/built-in-agent-helper-utilities.md +0 -123
  96. package/skills/runtime/references/built-in-agent-model-identifiers.md +0 -58
  97. package/skills/runtime/references/built-in-agent.md +0 -523
  98. package/skills/runtime/references/intelligence-mode.md +0 -364
  99. package/skills/runtime/references/middleware.md +0 -376
  100. package/skills/runtime/references/server-side-tools.md +0 -414
  101. package/skills/runtime/references/setup-endpoint.md +0 -503
  102. package/skills/runtime/references/transcription.md +0 -287
  103. package/skills/runtime/references/wiring-a2a.md +0 -40
  104. package/skills/runtime/references/wiring-adk.md +0 -45
  105. package/skills/runtime/references/wiring-ag2.md +0 -41
  106. package/skills/runtime/references/wiring-agno.md +0 -40
  107. package/skills/runtime/references/wiring-aws-strands.md +0 -59
  108. package/skills/runtime/references/wiring-crewai-crews.md +0 -51
  109. package/skills/runtime/references/wiring-crewai-flows.md +0 -45
  110. package/skills/runtime/references/wiring-external-agents.md +0 -348
  111. package/skills/runtime/references/wiring-langgraph.md +0 -49
  112. package/skills/runtime/references/wiring-llamaindex.md +0 -39
  113. package/skills/runtime/references/wiring-mastra.md +0 -70
  114. package/skills/runtime/references/wiring-mcp-apps-middleware.md +0 -73
  115. package/skills/runtime/references/wiring-ms-agent-framework.md +0 -41
  116. package/skills/runtime/references/wiring-pydantic-ai.md +0 -45
@@ -1,232 +0,0 @@
1
- BuiltInAgent Factory Modes — cookbook for TanStack AI, AI SDK, and custom AG-UI factories.
2
-
3
- ## The AgentFactoryContext
4
-
5
- ```typescript
6
- // packages/runtime/src/agent/index.ts
7
- export interface AgentFactoryContext {
8
- input: RunAgentInput; // messages, tools, forwardedProps, context
9
- abortController: AbortController; // prefer abortSignal
10
- abortSignal: AbortSignal; // pass to AI SDK / fetch / custom
11
- }
12
- ```
13
-
14
- Rule of thumb:
15
-
16
- - Prefer `abortSignal` for AI SDK, fetch, custom backends.
17
- - Use `abortController` for TanStack AI (its `chat()` takes the controller, not the signal).
18
- - NEVER call `ctx.abortController.abort()` inside the factory — use
19
- `agent.abortRun()` from outside.
20
-
21
- ## TanStack AI factory (preferred)
22
-
23
- ```typescript
24
- import { BuiltInAgent, convertInputToTanStackAI } from "@copilotkit/runtime/v2";
25
- import { chat } from "@tanstack/ai";
26
- import { openaiText } from "@tanstack/ai-openai";
27
-
28
- new BuiltInAgent({
29
- type: "tanstack",
30
- factory: ({ input, abortController }) => {
31
- const { messages, systemPrompts } = convertInputToTanStackAI(input);
32
- systemPrompts.unshift("You are a helpful assistant.");
33
- return chat({
34
- adapter: openaiText("gpt-4o"),
35
- messages,
36
- systemPrompts,
37
- tools: [
38
- /* TanStack AI toolDefinition()s */
39
- ],
40
- abortController,
41
- });
42
- },
43
- });
44
- ```
45
-
46
- ### TanStack AI + forwardedProps
47
-
48
- ```typescript
49
- new BuiltInAgent({
50
- type: "tanstack",
51
- factory: ({ input, abortController }) => {
52
- const { messages, systemPrompts } = convertInputToTanStackAI(input);
53
- const fwd = input.forwardedProps as
54
- | { model?: string; temperature?: number }
55
- | undefined;
56
- return chat({
57
- adapter: openaiText(fwd?.model ?? "gpt-4o"),
58
- messages,
59
- systemPrompts,
60
- modelOptions: { temperature: fwd?.temperature ?? 0.2 },
61
- abortController,
62
- });
63
- },
64
- });
65
- ```
66
-
67
- ## AI SDK factory (use when reasoning events are required)
68
-
69
- ```typescript
70
- import {
71
- BuiltInAgent,
72
- convertMessagesToVercelAISDKMessages,
73
- convertToolsToVercelAITools,
74
- } from "@copilotkit/runtime/v2";
75
- import { streamText, stepCountIs } from "ai";
76
- import { openai } from "@ai-sdk/openai";
77
-
78
- new BuiltInAgent({
79
- type: "aisdk",
80
- factory: ({ input, abortSignal }) => {
81
- const messages = convertMessagesToVercelAISDKMessages(input.messages, {
82
- forwardSystemMessages: true,
83
- });
84
- const tools = convertToolsToVercelAITools(input.tools);
85
- return streamText({
86
- model: openai("gpt-4o"),
87
- messages,
88
- tools,
89
- abortSignal,
90
- stopWhen: stepCountIs(5),
91
- });
92
- },
93
- });
94
- ```
95
-
96
- The `BuiltInAgentAISDKFactoryConfig` contract requires an object with a `fullStream`
97
- async iterable — this is exactly what `streamText()` returns.
98
-
99
- ## AI SDK + reasoning (Anthropic thinking)
100
-
101
- ```typescript
102
- import { anthropic } from "@ai-sdk/anthropic";
103
- import { streamText } from "ai";
104
- import {
105
- BuiltInAgent,
106
- convertMessagesToVercelAISDKMessages,
107
- } from "@copilotkit/runtime/v2";
108
-
109
- new BuiltInAgent({
110
- type: "aisdk",
111
- factory: ({ input, abortSignal }) =>
112
- streamText({
113
- model: anthropic("claude-sonnet-4-6"),
114
- messages: convertMessagesToVercelAISDKMessages(input.messages),
115
- providerOptions: {
116
- anthropic: { thinking: { type: "enabled", budgetTokens: 10000 } },
117
- },
118
- abortSignal,
119
- }),
120
- });
121
- ```
122
-
123
- TanStack AI silently drops reasoning events — only AI SDK surfaces them.
124
-
125
- ## Custom factory (raw AG-UI events)
126
-
127
- ```typescript
128
- import { BuiltInAgent } from "@copilotkit/runtime/v2";
129
- import type { BaseEvent } from "@ag-ui/client";
130
- import { EventType } from "@ag-ui/client";
131
-
132
- new BuiltInAgent({
133
- type: "custom",
134
- factory: async function* ({ input, abortSignal }): AsyncIterable<BaseEvent> {
135
- // Check abortSignal.aborted on every iteration — agent.abortRun() signals
136
- // cancellation via this flag, but the generator must consult it to stop yielding.
137
- if (abortSignal.aborted) return;
138
-
139
- const messageId = crypto.randomUUID();
140
- yield {
141
- type: EventType.TEXT_MESSAGE_START,
142
- messageId,
143
- role: "assistant",
144
- } as any;
145
-
146
- for (const delta of ["Hello", ", ", "world."]) {
147
- if (abortSignal.aborted) return; // honor cancellation between yields
148
- yield {
149
- type: EventType.TEXT_MESSAGE_CONTENT,
150
- messageId,
151
- delta,
152
- } as any;
153
- }
154
-
155
- yield { type: EventType.TEXT_MESSAGE_END, messageId } as any;
156
- },
157
- });
158
- ```
159
-
160
- A custom factory that never checks `abortSignal.aborted` (or registers an
161
- `addEventListener("abort", …)` handler to break its loop) is non-cancellable —
162
- `agent.abortRun()` will flip the flag but the generator will keep yielding until it
163
- exhausts its own source. Pass `abortSignal` through to any underlying `fetch` /
164
- streaming API as well so the upstream request is torn down.
165
-
166
- ## Manual state-tool wiring (Factory Mode only)
167
-
168
- Simple Mode auto-injects `AGUISendStateSnapshot` / `AGUISendStateDelta`. In Factory Mode
169
- you must register them by hand for shared-state updates to reach the LLM. The AI SDK
170
- factory works out of the box because `defineTool` output adapts through
171
- `convertToolDefinitionsToVercelAITools`:
172
-
173
- ```typescript
174
- import {
175
- BuiltInAgent,
176
- convertMessagesToVercelAISDKMessages,
177
- convertToolDefinitionsToVercelAITools,
178
- defineTool,
179
- } from "@copilotkit/runtime/v2";
180
- import { streamText } from "ai";
181
- import { openai } from "@ai-sdk/openai";
182
- import { z } from "zod";
183
-
184
- const sendStateSnapshot = defineTool({
185
- name: "AGUISendStateSnapshot",
186
- description: "Replace the entire application state with a new snapshot",
187
- parameters: z.object({
188
- snapshot: z.any().describe("The complete new state object"),
189
- }),
190
- execute: async ({ snapshot }) => ({ success: true, snapshot }),
191
- });
192
- const sendStateDelta = defineTool({
193
- name: "AGUISendStateDelta",
194
- description:
195
- "Apply incremental updates to application state using JSON Patch operations",
196
- // MUST mirror the Simple-Mode auto-injected schema (src/agent/index.ts:1140-1176)
197
- // or the frontend's state handler won't recognize the payload.
198
- parameters: z.object({
199
- delta: z
200
- .array(
201
- z.object({
202
- op: z.enum(["add", "replace", "remove"]),
203
- path: z.string(),
204
- value: z.any().optional(),
205
- }),
206
- )
207
- .describe("Array of JSON Patch operations"),
208
- }),
209
- execute: async ({ delta }) => ({ success: true, delta }),
210
- });
211
-
212
- new BuiltInAgent({
213
- type: "aisdk",
214
- factory: ({ input, abortSignal }) =>
215
- streamText({
216
- model: openai("gpt-4o"),
217
- messages: convertMessagesToVercelAISDKMessages(input.messages),
218
- tools: convertToolDefinitionsToVercelAITools([
219
- sendStateSnapshot,
220
- sendStateDelta,
221
- ]),
222
- abortSignal,
223
- }),
224
- });
225
- ```
226
-
227
- For TanStack AI factories, `defineTool` output is NOT a TanStack tool — passing it to
228
- `chat({ tools })` does not work. Either switch to the AI SDK factory above, or redefine
229
- the tools with `toolDefinition()` from `@tanstack/ai`.
230
-
231
- Source: `packages/runtime/src/agent/index.ts`,
232
- `docs/content/docs/integrations/built-in-agent/custom-agent.mdx`.
@@ -1,123 +0,0 @@
1
- BuiltInAgent helper utilities — exported from `@copilotkit/runtime/v2`.
2
-
3
- ## convertInputToTanStackAI
4
-
5
- ```typescript
6
- import { convertInputToTanStackAI } from "@copilotkit/runtime/v2";
7
-
8
- // signature (simplified):
9
- // convertInputToTanStackAI(input: RunAgentInput): {
10
- // messages: TanStackAIMessage[];
11
- // systemPrompts: string[];
12
- // }
13
- ```
14
-
15
- Converts the AG-UI `RunAgentInput` into TanStack AI's `chat()` inputs. System messages in
16
- the input are collected into the `systemPrompts` array (not the `messages` array). Unshift
17
- your own system prompt onto `systemPrompts` before calling `chat()`:
18
-
19
- ```typescript
20
- const { messages, systemPrompts } = convertInputToTanStackAI(input);
21
- systemPrompts.unshift("You are a helpful assistant.");
22
- return chat({ adapter, messages, systemPrompts, abortController });
23
- ```
24
-
25
- Source: `packages/runtime/src/agent/converters/tanstack.ts:156`.
26
-
27
- ## convertMessagesToVercelAISDKMessages
28
-
29
- ```typescript
30
- import { convertMessagesToVercelAISDKMessages } from "@copilotkit/runtime/v2";
31
-
32
- // signature:
33
- // convertMessagesToVercelAISDKMessages(
34
- // messages: Message[],
35
- // options?: { forwardSystemMessages?: boolean; forwardDeveloperMessages?: boolean }
36
- // ): ModelMessage[]
37
- ```
38
-
39
- Converts AG-UI `Message[]` to the Vercel AI SDK's `ModelMessage[]`. Handles multimodal
40
- content (text, image, audio/video/document, and legacy `binary`). By default drops
41
- `role: "system"` and `role: "developer"` messages — set the options to opt in.
42
-
43
- ```typescript
44
- const messages = convertMessagesToVercelAISDKMessages(input.messages, {
45
- forwardSystemMessages: true,
46
- });
47
- ```
48
-
49
- Source: `packages/runtime/src/agent/index.ts:435`.
50
-
51
- ## convertToolsToVercelAITools
52
-
53
- ```typescript
54
- import { convertToolsToVercelAITools } from "@copilotkit/runtime/v2";
55
-
56
- // signature:
57
- // convertToolsToVercelAITools(tools: RunAgentInput["tools"]): ToolSet
58
- ```
59
-
60
- Converts AG-UI `input.tools` (tools registered on the frontend — their parameters are plain
61
- JSON Schema) into the AI SDK's `ToolSet`. Throws `Invalid JSON schema for tool ${name}`
62
- when a tool's parameters aren't a JSON schema object. The resulting tools have no
63
- `execute` — the AI SDK emits tool-call events and the frontend handles them.
64
-
65
- ```typescript
66
- const tools = convertToolsToVercelAITools(input.tools);
67
- return streamText({ model, messages, tools, abortSignal });
68
- ```
69
-
70
- Source: `packages/runtime/src/agent/index.ts:599`.
71
-
72
- ## convertToolDefinitionsToVercelAITools
73
-
74
- ```typescript
75
- import { convertToolDefinitionsToVercelAITools } from "@copilotkit/runtime/v2";
76
-
77
- // signature:
78
- // convertToolDefinitionsToVercelAITools(tools: ToolDefinition[]): ToolSet
79
- ```
80
-
81
- Converts server-side `ToolDefinition[]` (Standard Schema V1 parameters + `execute`
82
- function) into an AI SDK `ToolSet`. Zod schemas pass through directly; non-Zod Standard
83
- Schema V1 parameters (Valibot, ArkType, ...) are converted to JSON Schema via
84
- `schemaToJsonSchema` and wrapped with `jsonSchema()` from `ai`.
85
-
86
- ```typescript
87
- import { defineTool } from "@copilotkit/runtime/v2";
88
- import { z } from "zod";
89
-
90
- const searchTool = defineTool({
91
- name: "search",
92
- description: "Search the web.",
93
- parameters: z.object({ query: z.string() }),
94
- execute: async ({ query }) => ({ results: [] }),
95
- });
96
-
97
- const tools = convertToolDefinitionsToVercelAITools([searchTool]);
98
- return streamText({ model, messages, tools, abortSignal });
99
- ```
100
-
101
- Source: `packages/runtime/src/agent/index.ts:633`.
102
-
103
- ## resolveModel
104
-
105
- ```typescript
106
- import { resolveModel } from "@copilotkit/runtime/v2";
107
-
108
- // signature:
109
- // resolveModel(spec: ModelSpecifier, apiKey?: string): LanguageModel
110
- ```
111
-
112
- Resolves a `"provider/model"` (or `"provider:model"`) string to a `LanguageModel`. If
113
- `spec` is already a `LanguageModel`, it's returned as-is. Throws
114
- `Invalid model string "..."` when the provider separator is missing.
115
-
116
- Supported providers: `openai`, `anthropic`, `google`/`gemini`/`google-gemini`, `vertex`.
117
- Unknown providers throw `Unknown provider "..." in "...". Supported: openai, anthropic, google (gemini).`
118
-
119
- ```typescript
120
- const model = resolveModel("openai/gpt-4o", process.env.OPENAI_API_KEY);
121
- ```
122
-
123
- Source: `packages/runtime/src/agent/index.ts:176-249`.
@@ -1,58 +0,0 @@
1
- BuiltInAgent model identifiers — the full set of `"provider/model"` strings that
2
- `resolveModel` accepts out of the box.
3
-
4
- ## Shape
5
-
6
- `"provider/model"` or `"provider:model"` — both separators are normalized. Case-insensitive on the provider segment.
7
-
8
- ```typescript
9
- new BuiltInAgent({ model: "openai/gpt-4o" });
10
- new BuiltInAgent({ model: "anthropic:claude-sonnet-4-6" });
11
- ```
12
-
13
- ## Supported providers
14
-
15
- | Provider | Env var | Notes |
16
- | ------------------------------------- | ------------------- | ---------------------------------- |
17
- | `openai` | `OPENAI_API_KEY` | Lazily creates `@ai-sdk/openai` |
18
- | `anthropic` | `ANTHROPIC_API_KEY` | Lazily creates `@ai-sdk/anthropic` |
19
- | `google` / `gemini` / `google-gemini` | `GOOGLE_API_KEY` | `@ai-sdk/google` under the hood |
20
- | `vertex` | (GCP auth) | `@ai-sdk/google-vertex` |
21
-
22
- Pass `apiKey` on the constructor to override env vars.
23
-
24
- ## Pinned identifiers in the union type
25
-
26
- These are the concrete strings typed in `BuiltInAgentModel`:
27
-
28
- ```
29
- openai/gpt-5 openai/gpt-5-mini
30
- openai/gpt-4.1 openai/gpt-4.1-mini openai/gpt-4.1-nano
31
- openai/gpt-4o openai/gpt-4o-mini
32
- openai/o3 openai/o3-mini openai/o4-mini
33
-
34
- anthropic/claude-sonnet-4-6 anthropic/claude-sonnet-4-5
35
- anthropic/claude-opus-4-8 anthropic/claude-haiku-4-5
36
-
37
- google/gemini-2.5-pro google/gemini-2.5-flash google/gemini-2.5-flash-lite
38
- ```
39
-
40
- Any other valid model id is still accepted — the type is
41
- `BuiltInAgentModel = "openai/gpt-5" | ... | (string & {})`, and the AI SDK provider will
42
- accept any id it knows about. The pinned union is for autocomplete, not an exhaustive allowlist.
43
-
44
- ## Passing a LanguageModel instance directly
45
-
46
- Instead of a string, pass a pre-configured `LanguageModel`:
47
-
48
- ```typescript
49
- import { BuiltInAgent } from "@copilotkit/runtime/v2";
50
- import { createOpenAI } from "@ai-sdk/openai";
51
-
52
- const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY });
53
- new BuiltInAgent({ model: openai("gpt-4o") });
54
- ```
55
-
56
- This bypasses `resolveModel` entirely.
57
-
58
- Source: `packages/runtime/src/agent/index.ts:82-109, 176-249`.