@yourgpt/llm-sdk 1.5.42 → 1.5.44

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 YourGPT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,27 +4,24 @@ Multi-provider LLM SDK with streaming. One API, any provider.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
- npm install @yourgpt/llm-sdk openai
9
- ```
10
-
11
- For Anthropic, install `@anthropic-ai/sdk` instead:
12
-
13
7
  ```bash
14
8
  npm install @yourgpt/llm-sdk @anthropic-ai/sdk
15
9
  ```
16
10
 
11
+ > For other providers (OpenAI, Google, xAI), see [Providers Documentation](https://copilot-sdk.yourgpt.ai/docs/providers).
12
+
17
13
  ## Quick Start
18
14
 
19
15
  ```ts
16
+ // app/api/chat/route.ts
20
17
  import { streamText } from "@yourgpt/llm-sdk";
21
- import { openai } from "@yourgpt/llm-sdk/openai";
18
+ import { anthropic } from "@yourgpt/llm-sdk/anthropic";
22
19
 
23
20
  export async function POST(req: Request) {
24
21
  const { messages } = await req.json();
25
22
 
26
23
  const result = await streamText({
27
- model: openai("gpt-4o"),
24
+ model: anthropic("claude-sonnet-4-20250514"),
28
25
  system: "You are a helpful assistant.",
29
26
  messages,
30
27
  });
@@ -33,104 +30,39 @@ export async function POST(req: Request) {
33
30
  }
34
31
  ```
35
32
 
36
- ## Multi-Provider Support
37
-
38
- ```ts
39
- import { openai } from "@yourgpt/llm-sdk/openai";
40
- import { anthropic } from "@yourgpt/llm-sdk/anthropic";
41
- import { google } from "@yourgpt/llm-sdk/google";
42
- import { xai } from "@yourgpt/llm-sdk/xai";
43
-
44
- // OpenAI
45
- await streamText({ model: openai("gpt-4o"), messages });
46
-
47
- // Anthropic
48
- await streamText({ model: anthropic("claude-sonnet-4-20250514"), messages });
49
-
50
- // Google Gemini (uses OpenAI-compatible API)
51
- await streamText({ model: google("gemini-2.0-flash"), messages });
52
-
53
- // xAI Grok (uses OpenAI-compatible API)
54
- await streamText({ model: xai("grok-3-fast"), messages });
55
- ```
56
-
57
- ## Server-Side Tools
58
-
59
- ```ts
60
- import { streamText, tool } from "@yourgpt/llm-sdk";
61
- import { openai } from "@yourgpt/llm-sdk/openai";
62
- import { z } from "zod";
63
-
64
- const result = await streamText({
65
- model: openai("gpt-4o"),
66
- messages,
67
- tools: {
68
- getWeather: tool({
69
- description: "Get current weather for a city",
70
- parameters: z.object({
71
- city: z.string().describe("City name"),
72
- }),
73
- execute: async ({ city }) => {
74
- return { temperature: 72, condition: "sunny" };
75
- },
76
- }),
77
- },
78
- maxSteps: 5,
79
- });
80
-
81
- return result.toDataStreamResponse();
33
+ ```bash
34
+ # .env.local
35
+ ANTHROPIC_API_KEY=sk-ant-...
82
36
  ```
83
37
 
84
- ## Express Integration
38
+ ## With Copilot SDK
85
39
 
86
- Use the `createRuntime()` API with the new `stream()` method for Express:
40
+ Use `createRuntime` for full Copilot SDK integration with tools support:
87
41
 
88
42
  ```ts
89
- import express from "express";
43
+ // app/api/chat/route.ts
90
44
  import { createRuntime } from "@yourgpt/llm-sdk";
91
- import { createOpenAI } from "@yourgpt/llm-sdk/openai";
92
-
93
- const app = express();
94
- app.use(express.json());
45
+ import { createAnthropic } from "@yourgpt/llm-sdk/anthropic";
95
46
 
96
47
  const runtime = createRuntime({
97
- provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY }),
98
- model: "gpt-4o",
99
- });
100
-
101
- // One-liner streaming endpoint
102
- app.post("/api/chat", async (req, res) => {
103
- await runtime.stream(req.body).pipeToResponse(res);
48
+ provider: createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY }),
49
+ model: "claude-sonnet-4-20250514",
50
+ systemPrompt: "You are a helpful assistant.",
104
51
  });
105
52
 
106
- app.listen(3001);
53
+ export async function POST(req: Request) {
54
+ return runtime.stream(await req.json()).toResponse();
55
+ }
107
56
  ```
108
57
 
109
- ### Available Response Methods
110
-
111
- | Method | Framework | Description |
112
- | -------------------------- | ------------- | --------------------------- |
113
- | `.toResponse()` | Next.js, Deno | Returns Web Response |
114
- | `.pipeToResponse(res)` | Express, Node | Pipes SSE to ServerResponse |
115
- | `.pipeTextToResponse(res)` | Express, Node | Pipes text only |
116
- | `.collect()` | Any | Collects full response |
117
-
118
- ## Supported Providers
119
-
120
- | Provider | Import | SDK Required |
121
- | ------------- | ---------------------------- | ------------------- |
122
- | OpenAI | `@yourgpt/llm-sdk/openai` | `openai` |
123
- | Anthropic | `@yourgpt/llm-sdk/anthropic` | `@anthropic-ai/sdk` |
124
- | Google Gemini | `@yourgpt/llm-sdk/google` | `openai` |
125
- | xAI (Grok) | `@yourgpt/llm-sdk/xai` | `openai` |
126
- | Ollama | `@yourgpt/llm-sdk/ollama` | `openai` |
127
- | Azure OpenAI | `@yourgpt/llm-sdk/azure` | `openai` |
128
-
129
- > **Note:** OpenAI, Google, xAI, Ollama, and Azure all use the `openai` SDK because they have OpenAI-compatible APIs. Only Anthropic requires its native SDK for full feature support.
130
-
131
58
  ## Documentation
132
59
 
133
- Visit [copilot-sdk.yourgpt.ai](https://copilot-sdk.yourgpt.ai)
60
+ Visit **[copilot-sdk.yourgpt.ai](https://copilot-sdk.yourgpt.ai)** for full documentation:
61
+
62
+ - [All Providers](https://copilot-sdk.yourgpt.ai/docs/providers) - OpenAI, Anthropic, Google, xAI
63
+ - [Server Setup](https://copilot-sdk.yourgpt.ai/docs/server) - Runtime, streaming, tools
64
+ - [Tools](https://copilot-sdk.yourgpt.ai/docs/tools) - Server-side and client-side tools
65
+ - [LLM SDK Reference](https://copilot-sdk.yourgpt.ai/docs/llm-sdk) - streamText, generateText
134
66
 
135
67
  ## License
136
68
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, L as LLMAdapter, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.mjs';
1
+ import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, L as LLMAdapter, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.mjs';
2
2
  export { P as AdapterFactory, o as AssistantMessage, O as ChatCompletionRequest, C as CoreMessage, N as DEFAULT_CAPABILITIES, l as DoGenerateParams, m as DoGenerateResult, E as ErrorChunk, F as FilePart, B as FinishChunk, J as FinishReason, u as GenerateStep, I as ImagePart, Q as LLMConfig, j as LanguageModel, k as ModelCapabilities, R as ResponseOptions, w as StreamChunk, v as StreamPart, n as SystemMessage, x as TextDeltaChunk, r as TextPart, H as TokenUsage, s as ToolCall, y as ToolCallChunk, Y as ToolExecution, V as ToolLocation, p as ToolMessage, t as ToolResult, z as ToolResultChunk, W as UnifiedToolCall, X as UnifiedToolResult, q as UserContentPart, U as UserMessage } from './base-DdxolpKP.mjs';
3
3
  import { z } from 'zod';
4
4
  import { A as AIProvider } from './types-Ck25ZYma.mjs';
@@ -167,68 +167,11 @@ declare function formatToolsForGoogle(tools: Record<string, Tool>): Array<{
167
167
  }>;
168
168
 
169
169
  /**
170
- * LLM provider type for server-side configuration
171
- */
172
- type LLMProvider = "openai" | "anthropic" | "google" | "ollama" | "xai" | "azure";
173
- /**
174
- * Server-side LLM configuration (complete config for runtime)
175
- */
176
- interface ServerLLMConfig {
177
- /** LLM provider */
178
- provider: LLMProvider;
179
- /** API key for the provider */
180
- apiKey: string;
181
- /** Model name */
182
- model?: string;
183
- /** Base URL for custom/self-hosted models */
184
- baseUrl?: string;
185
- /** Temperature (0-2) */
186
- temperature?: number;
187
- /** Maximum tokens in response */
188
- maxTokens?: number;
189
- }
190
- /**
191
- * Runtime configuration with LLM config
192
- */
193
- interface RuntimeConfigWithLLM {
194
- /** LLM configuration */
195
- llm: ServerLLMConfig;
196
- /** Custom LLM adapter (overrides llm config) */
197
- adapter?: LLMAdapter;
198
- /** System prompt */
199
- systemPrompt?: string;
200
- /** Available actions (legacy) */
201
- actions?: ActionDefinition[];
202
- /** Available tools (new - supports location: server/client) */
203
- tools?: ToolDefinition[];
204
- /** Agent loop configuration */
205
- agentLoop?: AgentLoopConfig;
206
- /** Knowledge base configuration (enables search_knowledge tool) */
207
- knowledgeBase?: KnowledgeBaseConfig;
208
- /** Enable debug logging */
209
- debug?: boolean;
210
- /**
211
- * Custom context data passed to all tool handlers.
212
- * Useful for passing auth tokens, user info, tenant data, etc.
213
- *
214
- * @example
215
- * ```typescript
216
- * const runtime = createRuntime({
217
- * llm: { ... },
218
- * toolContext: { userId: session.userId, tenantId: tenant.id },
219
- * });
220
- * ```
221
- */
222
- toolContext?: Record<string, unknown>;
223
- }
224
- /**
225
- * Runtime configuration with adapter
170
+ * Runtime configuration with adapter (advanced usage)
226
171
  */
227
172
  interface RuntimeConfigWithAdapter {
228
173
  /** Custom LLM adapter */
229
174
  adapter: LLMAdapter;
230
- /** LLM configuration (optional when adapter provided) */
231
- llm?: ServerLLMConfig;
232
175
  /** System prompt */
233
176
  systemPrompt?: string;
234
177
  /** Available actions (legacy) */
@@ -279,9 +222,23 @@ interface RuntimeConfigWithProvider {
279
222
  toolContext?: Record<string, unknown>;
280
223
  }
281
224
  /**
282
- * Runtime configuration - either provide llm config, adapter, or provider
225
+ * Runtime configuration - provide either a provider instance or a custom adapter
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // Recommended: Use provider instance
230
+ * const runtime = createRuntime({
231
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY }),
232
+ * model: 'gpt-4o',
233
+ * });
234
+ *
235
+ * // Advanced: Use custom adapter
236
+ * const runtime = createRuntime({
237
+ * adapter: myCustomAdapter,
238
+ * });
239
+ * ```
283
240
  */
284
- type RuntimeConfig = RuntimeConfigWithLLM | RuntimeConfigWithAdapter | RuntimeConfigWithProvider;
241
+ type RuntimeConfig = RuntimeConfigWithProvider | RuntimeConfigWithAdapter;
285
242
  /**
286
243
  * Message attachment (images, files, etc.)
287
244
  */
@@ -823,10 +780,6 @@ declare class Runtime {
823
780
  private actions;
824
781
  private tools;
825
782
  constructor(config: RuntimeConfig);
826
- /**
827
- * Create LLM adapter based on config
828
- */
829
- private createAdapter;
830
783
  /**
831
784
  * Process a chat request and return streaming response
832
785
  */
@@ -887,10 +840,6 @@ declare class Runtime {
887
840
  * Get registered tools
888
841
  */
889
842
  getTools(): ToolDefinition[];
890
- /**
891
- * Get the AI provider name from config
892
- */
893
- private getProviderName;
894
843
  /**
895
844
  * Get the AI provider instance (if using provider config)
896
845
  */
@@ -1152,16 +1101,36 @@ declare function createHonoApp(runtime: Runtime): Hono;
1152
1101
  /**
1153
1102
  * Next.js App Router handler
1154
1103
  *
1104
+ * For simple Next.js routes, prefer using `streamText()` directly:
1105
+ * @example
1106
+ * ```ts
1107
+ * // app/api/chat/route.ts (RECOMMENDED)
1108
+ * import { streamText } from '@yourgpt/llm-sdk';
1109
+ * import { openai } from '@yourgpt/llm-sdk/openai';
1110
+ *
1111
+ * export async function POST(req: Request) {
1112
+ * const { messages } = await req.json();
1113
+ * const result = await streamText({
1114
+ * model: openai('gpt-4o'),
1115
+ * system: 'You are a helpful assistant.',
1116
+ * messages,
1117
+ * });
1118
+ * return result.toTextStreamResponse();
1119
+ * }
1120
+ * ```
1121
+ *
1122
+ * Use createNextHandler when you need runtime features like tools:
1155
1123
  * @example
1156
1124
  * ```ts
1157
1125
  * // app/api/chat/route.ts
1158
1126
  * import { createNextHandler } from '@yourgpt/llm-sdk';
1127
+ * import { createOpenAI } from '@yourgpt/llm-sdk/openai';
1159
1128
  *
1160
- * const handler = createNextHandler({
1161
- * llm: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY! },
1129
+ * export const POST = createNextHandler({
1130
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY! }),
1131
+ * model: 'gpt-4o',
1132
+ * systemPrompt: 'You are a helpful assistant.',
1162
1133
  * });
1163
- *
1164
- * export const POST = handler;
1165
1134
  * ```
1166
1135
  */
1167
1136
  declare function createNextHandler(config: RuntimeConfig): (request: Request) => Promise<Response>;
@@ -1255,9 +1224,12 @@ declare function createExpressHandler(runtime: Runtime, options?: {
1255
1224
  * ```ts
1256
1225
  * import http from 'http';
1257
1226
  * import { createNodeHandler } from '@yourgpt/llm-sdk';
1227
+ * import { createOpenAI } from '@yourgpt/llm-sdk/openai';
1258
1228
  *
1259
1229
  * const handler = createNodeHandler({
1260
- * llm: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY! },
1230
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY! }),
1231
+ * model: 'gpt-4o',
1232
+ * systemPrompt: 'You are a helpful assistant.',
1261
1233
  * });
1262
1234
  *
1263
1235
  * const server = http.createServer(handler);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, L as LLMAdapter, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.js';
1
+ import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as ActionDefinition, d as ToolDefinition, e as AgentLoopConfig, K as KnowledgeBaseConfig, L as LLMAdapter, D as DoneEventMessage, f as StreamEvent, g as ToolCallInfo, h as TokenUsageRaw, M as Message, i as ToolResponse } from './base-DdxolpKP.js';
2
2
  export { P as AdapterFactory, o as AssistantMessage, O as ChatCompletionRequest, C as CoreMessage, N as DEFAULT_CAPABILITIES, l as DoGenerateParams, m as DoGenerateResult, E as ErrorChunk, F as FilePart, B as FinishChunk, J as FinishReason, u as GenerateStep, I as ImagePart, Q as LLMConfig, j as LanguageModel, k as ModelCapabilities, R as ResponseOptions, w as StreamChunk, v as StreamPart, n as SystemMessage, x as TextDeltaChunk, r as TextPart, H as TokenUsage, s as ToolCall, y as ToolCallChunk, Y as ToolExecution, V as ToolLocation, p as ToolMessage, t as ToolResult, z as ToolResultChunk, W as UnifiedToolCall, X as UnifiedToolResult, q as UserContentPart, U as UserMessage } from './base-DdxolpKP.js';
3
3
  import { z } from 'zod';
4
4
  import { A as AIProvider } from './types-Dsz8SpdB.js';
@@ -167,68 +167,11 @@ declare function formatToolsForGoogle(tools: Record<string, Tool>): Array<{
167
167
  }>;
168
168
 
169
169
  /**
170
- * LLM provider type for server-side configuration
171
- */
172
- type LLMProvider = "openai" | "anthropic" | "google" | "ollama" | "xai" | "azure";
173
- /**
174
- * Server-side LLM configuration (complete config for runtime)
175
- */
176
- interface ServerLLMConfig {
177
- /** LLM provider */
178
- provider: LLMProvider;
179
- /** API key for the provider */
180
- apiKey: string;
181
- /** Model name */
182
- model?: string;
183
- /** Base URL for custom/self-hosted models */
184
- baseUrl?: string;
185
- /** Temperature (0-2) */
186
- temperature?: number;
187
- /** Maximum tokens in response */
188
- maxTokens?: number;
189
- }
190
- /**
191
- * Runtime configuration with LLM config
192
- */
193
- interface RuntimeConfigWithLLM {
194
- /** LLM configuration */
195
- llm: ServerLLMConfig;
196
- /** Custom LLM adapter (overrides llm config) */
197
- adapter?: LLMAdapter;
198
- /** System prompt */
199
- systemPrompt?: string;
200
- /** Available actions (legacy) */
201
- actions?: ActionDefinition[];
202
- /** Available tools (new - supports location: server/client) */
203
- tools?: ToolDefinition[];
204
- /** Agent loop configuration */
205
- agentLoop?: AgentLoopConfig;
206
- /** Knowledge base configuration (enables search_knowledge tool) */
207
- knowledgeBase?: KnowledgeBaseConfig;
208
- /** Enable debug logging */
209
- debug?: boolean;
210
- /**
211
- * Custom context data passed to all tool handlers.
212
- * Useful for passing auth tokens, user info, tenant data, etc.
213
- *
214
- * @example
215
- * ```typescript
216
- * const runtime = createRuntime({
217
- * llm: { ... },
218
- * toolContext: { userId: session.userId, tenantId: tenant.id },
219
- * });
220
- * ```
221
- */
222
- toolContext?: Record<string, unknown>;
223
- }
224
- /**
225
- * Runtime configuration with adapter
170
+ * Runtime configuration with adapter (advanced usage)
226
171
  */
227
172
  interface RuntimeConfigWithAdapter {
228
173
  /** Custom LLM adapter */
229
174
  adapter: LLMAdapter;
230
- /** LLM configuration (optional when adapter provided) */
231
- llm?: ServerLLMConfig;
232
175
  /** System prompt */
233
176
  systemPrompt?: string;
234
177
  /** Available actions (legacy) */
@@ -279,9 +222,23 @@ interface RuntimeConfigWithProvider {
279
222
  toolContext?: Record<string, unknown>;
280
223
  }
281
224
  /**
282
- * Runtime configuration - either provide llm config, adapter, or provider
225
+ * Runtime configuration - provide either a provider instance or a custom adapter
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // Recommended: Use provider instance
230
+ * const runtime = createRuntime({
231
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY }),
232
+ * model: 'gpt-4o',
233
+ * });
234
+ *
235
+ * // Advanced: Use custom adapter
236
+ * const runtime = createRuntime({
237
+ * adapter: myCustomAdapter,
238
+ * });
239
+ * ```
283
240
  */
284
- type RuntimeConfig = RuntimeConfigWithLLM | RuntimeConfigWithAdapter | RuntimeConfigWithProvider;
241
+ type RuntimeConfig = RuntimeConfigWithProvider | RuntimeConfigWithAdapter;
285
242
  /**
286
243
  * Message attachment (images, files, etc.)
287
244
  */
@@ -823,10 +780,6 @@ declare class Runtime {
823
780
  private actions;
824
781
  private tools;
825
782
  constructor(config: RuntimeConfig);
826
- /**
827
- * Create LLM adapter based on config
828
- */
829
- private createAdapter;
830
783
  /**
831
784
  * Process a chat request and return streaming response
832
785
  */
@@ -887,10 +840,6 @@ declare class Runtime {
887
840
  * Get registered tools
888
841
  */
889
842
  getTools(): ToolDefinition[];
890
- /**
891
- * Get the AI provider name from config
892
- */
893
- private getProviderName;
894
843
  /**
895
844
  * Get the AI provider instance (if using provider config)
896
845
  */
@@ -1152,16 +1101,36 @@ declare function createHonoApp(runtime: Runtime): Hono;
1152
1101
  /**
1153
1102
  * Next.js App Router handler
1154
1103
  *
1104
+ * For simple Next.js routes, prefer using `streamText()` directly:
1105
+ * @example
1106
+ * ```ts
1107
+ * // app/api/chat/route.ts (RECOMMENDED)
1108
+ * import { streamText } from '@yourgpt/llm-sdk';
1109
+ * import { openai } from '@yourgpt/llm-sdk/openai';
1110
+ *
1111
+ * export async function POST(req: Request) {
1112
+ * const { messages } = await req.json();
1113
+ * const result = await streamText({
1114
+ * model: openai('gpt-4o'),
1115
+ * system: 'You are a helpful assistant.',
1116
+ * messages,
1117
+ * });
1118
+ * return result.toTextStreamResponse();
1119
+ * }
1120
+ * ```
1121
+ *
1122
+ * Use createNextHandler when you need runtime features like tools:
1155
1123
  * @example
1156
1124
  * ```ts
1157
1125
  * // app/api/chat/route.ts
1158
1126
  * import { createNextHandler } from '@yourgpt/llm-sdk';
1127
+ * import { createOpenAI } from '@yourgpt/llm-sdk/openai';
1159
1128
  *
1160
- * const handler = createNextHandler({
1161
- * llm: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY! },
1129
+ * export const POST = createNextHandler({
1130
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY! }),
1131
+ * model: 'gpt-4o',
1132
+ * systemPrompt: 'You are a helpful assistant.',
1162
1133
  * });
1163
- *
1164
- * export const POST = handler;
1165
1134
  * ```
1166
1135
  */
1167
1136
  declare function createNextHandler(config: RuntimeConfig): (request: Request) => Promise<Response>;
@@ -1255,9 +1224,12 @@ declare function createExpressHandler(runtime: Runtime, options?: {
1255
1224
  * ```ts
1256
1225
  * import http from 'http';
1257
1226
  * import { createNodeHandler } from '@yourgpt/llm-sdk';
1227
+ * import { createOpenAI } from '@yourgpt/llm-sdk/openai';
1258
1228
  *
1259
1229
  * const handler = createNodeHandler({
1260
- * llm: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY! },
1230
+ * provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY! }),
1231
+ * model: 'gpt-4o',
1232
+ * systemPrompt: 'You are a helpful assistant.',
1261
1233
  * });
1262
1234
  *
1263
1235
  * const server = http.createServer(handler);