@standardagents/openrouter 0.11.4 → 0.11.6
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/dist/index.d.ts +42 -3
- package/dist/index.js +712 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ import { z } from 'zod';
|
|
|
27
27
|
* },
|
|
28
28
|
* }
|
|
29
29
|
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Use the Responses API (beta) instead of Chat Completions
|
|
34
|
+
* providerOptions: {
|
|
35
|
+
* useResponsesApi: true,
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
30
38
|
*/
|
|
31
39
|
declare const openrouterProviderOptions: z.ZodObject<{
|
|
32
40
|
provider: z.ZodOptional<z.ZodObject<{
|
|
@@ -86,6 +94,7 @@ declare const openrouterProviderOptions: z.ZodObject<{
|
|
|
86
94
|
}, z.core.$strip>]>>;
|
|
87
95
|
enforce_distillable_text: z.ZodOptional<z.ZodBoolean>;
|
|
88
96
|
}, z.core.$loose>>;
|
|
97
|
+
useResponsesApi: z.ZodOptional<z.ZodBoolean>;
|
|
89
98
|
}, z.core.$loose>;
|
|
90
99
|
/**
|
|
91
100
|
* TypeScript type for OpenRouter provider options.
|
|
@@ -100,11 +109,19 @@ interface OpenRouterConfig extends ProviderFactoryConfig {
|
|
|
100
109
|
/** List of providers to route to (e.g., ['openai', 'anthropic']) */
|
|
101
110
|
providers?: string[];
|
|
102
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* API mode for OpenRouter requests.
|
|
114
|
+
* - 'chat': OpenAI-compatible Chat Completions API (default, stable)
|
|
115
|
+
* - 'responses': OpenRouter Responses API (beta, additional features)
|
|
116
|
+
*/
|
|
117
|
+
type OpenRouterApiMode = 'chat' | 'responses';
|
|
103
118
|
/**
|
|
104
119
|
* OpenRouter provider implementation for Standard Agents
|
|
105
120
|
*
|
|
106
|
-
*
|
|
121
|
+
* By default, uses the OpenAI-compatible Chat Completions API which is stable and well-tested.
|
|
107
122
|
* OpenRouter is a multi-provider gateway that routes requests to various LLM providers.
|
|
123
|
+
*
|
|
124
|
+
* To use the Responses API (beta), set `useResponsesApi: true` in providerOptions.
|
|
108
125
|
*/
|
|
109
126
|
declare class OpenRouterProvider implements LLMProviderInterface {
|
|
110
127
|
readonly name = "openrouter";
|
|
@@ -112,6 +129,12 @@ declare class OpenRouterProvider implements LLMProviderInterface {
|
|
|
112
129
|
private client;
|
|
113
130
|
private config;
|
|
114
131
|
constructor(config: OpenRouterConfig);
|
|
132
|
+
/**
|
|
133
|
+
* Determine which API to use for a request.
|
|
134
|
+
* Checks request-level providerOptions first, then falls back to config.
|
|
135
|
+
* Defaults to Chat Completions (stable API).
|
|
136
|
+
*/
|
|
137
|
+
private getApiMode;
|
|
115
138
|
private getClient;
|
|
116
139
|
supportsModel(_modelId: string): boolean;
|
|
117
140
|
/**
|
|
@@ -142,7 +165,23 @@ declare class OpenRouterProvider implements LLMProviderInterface {
|
|
|
142
165
|
getModels(filter?: string): Promise<ProviderModelInfo[]>;
|
|
143
166
|
private mapToProviderModelInfo;
|
|
144
167
|
generate(request: ProviderRequest): Promise<ProviderResponse>;
|
|
168
|
+
/**
|
|
169
|
+
* Generate using the Chat Completions API (default).
|
|
170
|
+
*/
|
|
171
|
+
private generateWithChat;
|
|
172
|
+
/**
|
|
173
|
+
* Generate using the Responses API (beta).
|
|
174
|
+
*/
|
|
175
|
+
private generateWithResponses;
|
|
145
176
|
stream(request: ProviderRequest): Promise<AsyncIterable<ProviderStreamChunk>>;
|
|
177
|
+
/**
|
|
178
|
+
* Stream using the Chat Completions API (default).
|
|
179
|
+
*/
|
|
180
|
+
private streamWithChat;
|
|
181
|
+
/**
|
|
182
|
+
* Stream using the Responses API (beta).
|
|
183
|
+
*/
|
|
184
|
+
private streamWithResponses;
|
|
146
185
|
/**
|
|
147
186
|
* Fetch additional metadata about a completed response.
|
|
148
187
|
* Called asynchronously after the response is received.
|
|
@@ -153,7 +192,7 @@ declare class OpenRouterProvider implements LLMProviderInterface {
|
|
|
153
192
|
getResponseMetadata(summary: ResponseSummary, signal?: AbortSignal): Promise<Record<string, unknown> | null>;
|
|
154
193
|
private toProviderError;
|
|
155
194
|
/**
|
|
156
|
-
* Transform a ProviderRequest to
|
|
195
|
+
* Transform a ProviderRequest to the appropriate API format for inspection.
|
|
157
196
|
* Returns the exact request body that would be sent to OpenRouter, with base64 data truncated.
|
|
158
197
|
*/
|
|
159
198
|
inspectRequest(request: ProviderRequest): Promise<InspectedRequest>;
|
|
@@ -234,4 +273,4 @@ declare function fetchGenerationMetadata(apiKey: string, generationId: string, b
|
|
|
234
273
|
*/
|
|
235
274
|
declare const openrouter: ProviderFactoryWithOptions<typeof openrouterProviderOptions>;
|
|
236
275
|
|
|
237
|
-
export { type GenerationMetadata, type OpenRouterConfig, OpenRouterProvider, type OpenRouterProviderOptions, fetchGenerationMetadata, openrouter, openrouterProviderOptions };
|
|
276
|
+
export { type GenerationMetadata, type OpenRouterApiMode, type OpenRouterConfig, OpenRouterProvider, type OpenRouterProviderOptions, fetchGenerationMetadata, openrouter, openrouterProviderOptions };
|