@synova-cloud/sdk 1.4.0 → 1.6.0
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/README.md +23 -92
- package/dist/index.cjs +7 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -146
- package/dist/index.d.ts +42 -146
- package/dist/index.js +7 -123
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -102,8 +102,10 @@ interface ISynovaExecuteOptions {
|
|
|
102
102
|
provider: string;
|
|
103
103
|
/** LLM model to use (e.g., 'gpt-4o', 'claude-sonnet-4-20250514') */
|
|
104
104
|
model: string;
|
|
105
|
-
/**
|
|
106
|
-
|
|
105
|
+
/** Raw API key for the LLM provider */
|
|
106
|
+
apiKey?: string;
|
|
107
|
+
/** Azure OpenAI endpoint URL (required for azure_openai provider) */
|
|
108
|
+
azureEndpoint?: string;
|
|
107
109
|
/** Variables to substitute in prompt template */
|
|
108
110
|
variables?: Record<string, unknown>;
|
|
109
111
|
/** Previous messages for multi-turn conversation */
|
|
@@ -135,13 +137,38 @@ interface ISynovaExecutionUsage {
|
|
|
135
137
|
/** Prediction time in seconds (when type='time') */
|
|
136
138
|
predictTimeSeconds?: number;
|
|
137
139
|
}
|
|
140
|
+
interface ISynovaProviderResponse {
|
|
141
|
+
/** HTTP status code from the LLM provider */
|
|
142
|
+
statusCode?: number;
|
|
143
|
+
/** Error message from the LLM provider */
|
|
144
|
+
message?: string;
|
|
145
|
+
}
|
|
146
|
+
interface ISynovaExecutionErrorDetails {
|
|
147
|
+
/** Model used for the execution */
|
|
148
|
+
model?: string;
|
|
149
|
+
/** Last 5 characters of the API key used (for debugging) */
|
|
150
|
+
apiKeyHint?: string;
|
|
151
|
+
/** Prompt ID (if execution was via prompt) */
|
|
152
|
+
promptId?: string;
|
|
153
|
+
/** Prompt version (if execution was via prompt) */
|
|
154
|
+
promptVersion?: string;
|
|
155
|
+
/** Execution log ID for debugging */
|
|
156
|
+
executionLogId?: string;
|
|
157
|
+
/** Input tokens count (for CONTEXT_TOO_LONG errors) */
|
|
158
|
+
inputTokens?: number;
|
|
159
|
+
/** Model context window limit (for CONTEXT_TOO_LONG errors) */
|
|
160
|
+
contextLimit?: number;
|
|
161
|
+
}
|
|
138
162
|
interface ISynovaExecutionError {
|
|
139
163
|
code: string;
|
|
140
164
|
message: string;
|
|
141
165
|
provider?: string;
|
|
142
166
|
retryable: boolean;
|
|
143
167
|
retryAfterMs?: number;
|
|
144
|
-
|
|
168
|
+
/** Raw response from the LLM provider's API */
|
|
169
|
+
providerResponse?: ISynovaProviderResponse;
|
|
170
|
+
/** Our context details */
|
|
171
|
+
details?: ISynovaExecutionErrorDetails;
|
|
145
172
|
}
|
|
146
173
|
interface ISynovaFileThumbnails {
|
|
147
174
|
/** Small thumbnail URL (120px width) */
|
|
@@ -249,49 +276,6 @@ interface ISynovaUploadOptions {
|
|
|
249
276
|
/** Project ID to associate files with */
|
|
250
277
|
projectId: string;
|
|
251
278
|
}
|
|
252
|
-
type TSynovaLlmProvider = 'openai' | 'anthropic' | 'google' | 'azure_openai' | 'deepseek' | 'replicate' | 'xai' | 'openrouter';
|
|
253
|
-
interface ISynovaAzureConfig {
|
|
254
|
-
/** Azure OpenAI endpoint URL */
|
|
255
|
-
endpoint: string;
|
|
256
|
-
}
|
|
257
|
-
interface ISynovaLlmProviderKey {
|
|
258
|
-
/** Key ID */
|
|
259
|
-
id: string;
|
|
260
|
-
/** LLM provider */
|
|
261
|
-
provider: TSynovaLlmProvider;
|
|
262
|
-
/** Masked API key (last 4 characters visible) */
|
|
263
|
-
maskedKey: string;
|
|
264
|
-
/** Whether this is the default key for the provider */
|
|
265
|
-
isDefault: boolean;
|
|
266
|
-
/** Default model for this provider */
|
|
267
|
-
defaultModel?: string;
|
|
268
|
-
/** Azure OpenAI configuration */
|
|
269
|
-
azure?: ISynovaAzureConfig;
|
|
270
|
-
/** Optional label to identify this key */
|
|
271
|
-
label?: string;
|
|
272
|
-
/** Creation date (ISO 8601) */
|
|
273
|
-
createdAt: string;
|
|
274
|
-
/** Last update date (ISO 8601) */
|
|
275
|
-
updatedAt: string;
|
|
276
|
-
}
|
|
277
|
-
interface ISynovaLlmProviderKeyListResponse {
|
|
278
|
-
items: ISynovaLlmProviderKey[];
|
|
279
|
-
total: number;
|
|
280
|
-
}
|
|
281
|
-
interface ISynovaCreateLlmProviderKeyOptions {
|
|
282
|
-
/** LLM provider */
|
|
283
|
-
provider: TSynovaLlmProvider;
|
|
284
|
-
/** API key for the LLM provider */
|
|
285
|
-
apiKey: string;
|
|
286
|
-
/** Whether this is the default key for the provider */
|
|
287
|
-
isDefault?: boolean;
|
|
288
|
-
/** Default model for this provider */
|
|
289
|
-
defaultModel?: string;
|
|
290
|
-
/** Azure OpenAI configuration (required for azure_openai provider) */
|
|
291
|
-
azure?: ISynovaAzureConfig;
|
|
292
|
-
/** Optional label to identify this key */
|
|
293
|
-
label?: string;
|
|
294
|
-
}
|
|
295
279
|
interface IApiErrorResponse {
|
|
296
280
|
code: string;
|
|
297
281
|
httpCode: number;
|
|
@@ -529,95 +513,6 @@ declare class FilesResource {
|
|
|
529
513
|
upload(files: (File | Blob)[], options: ISynovaUploadOptions): Promise<ISynovaUploadResponse>;
|
|
530
514
|
}
|
|
531
515
|
|
|
532
|
-
declare class LlmProviderKeysResource {
|
|
533
|
-
private readonly http;
|
|
534
|
-
constructor(http: HttpClient);
|
|
535
|
-
/**
|
|
536
|
-
* List all LLM provider keys
|
|
537
|
-
*
|
|
538
|
-
* @returns List of LLM provider keys
|
|
539
|
-
*
|
|
540
|
-
* @example
|
|
541
|
-
* ```ts
|
|
542
|
-
* const { items, total } = await client.llmProviderKeys.list();
|
|
543
|
-
* console.log(`Found ${total} keys`);
|
|
544
|
-
* for (const key of items) {
|
|
545
|
-
* console.log(`${key.provider}: ${key.maskedKey} (default: ${key.isDefault})`);
|
|
546
|
-
* }
|
|
547
|
-
* ```
|
|
548
|
-
*/
|
|
549
|
-
list(): Promise<ISynovaLlmProviderKeyListResponse>;
|
|
550
|
-
/**
|
|
551
|
-
* Get an LLM provider key by ID
|
|
552
|
-
*
|
|
553
|
-
* @param id - Key ID (e.g., 'lpk_abc123')
|
|
554
|
-
* @returns LLM provider key details
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* const key = await client.llmProviderKeys.get('lpk_abc123');
|
|
559
|
-
* console.log(`Provider: ${key.provider}, Default: ${key.isDefault}`);
|
|
560
|
-
* ```
|
|
561
|
-
*/
|
|
562
|
-
get(id: string): Promise<ISynovaLlmProviderKey>;
|
|
563
|
-
/**
|
|
564
|
-
* Create a new LLM provider key
|
|
565
|
-
*
|
|
566
|
-
* The first key created for a provider will automatically be set as the default.
|
|
567
|
-
*
|
|
568
|
-
* @param options - Key creation options
|
|
569
|
-
* @returns Created LLM provider key
|
|
570
|
-
*
|
|
571
|
-
* @example
|
|
572
|
-
* ```ts
|
|
573
|
-
* // Create OpenAI key
|
|
574
|
-
* const key = await client.llmProviderKeys.create({
|
|
575
|
-
* provider: 'openai',
|
|
576
|
-
* apiKey: 'sk-...',
|
|
577
|
-
* label: 'Production Key',
|
|
578
|
-
* defaultModel: 'gpt-4o',
|
|
579
|
-
* });
|
|
580
|
-
*
|
|
581
|
-
* // Create Azure OpenAI key
|
|
582
|
-
* const azureKey = await client.llmProviderKeys.create({
|
|
583
|
-
* provider: 'azure_openai',
|
|
584
|
-
* apiKey: 'your-azure-key',
|
|
585
|
-
* azure: {
|
|
586
|
-
* endpoint: 'https://my-resource.openai.azure.com',
|
|
587
|
-
* },
|
|
588
|
-
* label: 'Azure Production',
|
|
589
|
-
* });
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
create(options: ISynovaCreateLlmProviderKeyOptions): Promise<ISynovaLlmProviderKey>;
|
|
593
|
-
/**
|
|
594
|
-
* Set an LLM provider key as the default for its provider
|
|
595
|
-
*
|
|
596
|
-
* The previous default key for this provider will be unset.
|
|
597
|
-
*
|
|
598
|
-
* @param id - Key ID to set as default
|
|
599
|
-
* @returns Updated LLM provider key
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* ```ts
|
|
603
|
-
* const key = await client.llmProviderKeys.setDefault('lpk_abc123');
|
|
604
|
-
* console.log(`${key.id} is now the default for ${key.provider}`);
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
setDefault(id: string): Promise<ISynovaLlmProviderKey>;
|
|
608
|
-
/**
|
|
609
|
-
* Delete an LLM provider key
|
|
610
|
-
*
|
|
611
|
-
* @param id - Key ID to delete
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
* ```ts
|
|
615
|
-
* await client.llmProviderKeys.delete('lpk_abc123');
|
|
616
|
-
* ```
|
|
617
|
-
*/
|
|
618
|
-
delete(id: string): Promise<void>;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
516
|
/**
|
|
622
517
|
* Synova Cloud SDK client
|
|
623
518
|
*
|
|
@@ -630,10 +525,20 @@ declare class LlmProviderKeysResource {
|
|
|
630
525
|
* // Get a prompt
|
|
631
526
|
* const prompt = await client.prompts.get('prm_abc123');
|
|
632
527
|
*
|
|
633
|
-
* // Execute a prompt
|
|
528
|
+
* // Execute a prompt with direct API key
|
|
634
529
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
635
530
|
* provider: 'openai',
|
|
636
531
|
* model: 'gpt-4o',
|
|
532
|
+
* apiKey: 'sk-...',
|
|
533
|
+
* variables: { topic: 'TypeScript' },
|
|
534
|
+
* });
|
|
535
|
+
*
|
|
536
|
+
* // Execute with Azure OpenAI
|
|
537
|
+
* const azureResult = await client.prompts.execute('prm_abc123', {
|
|
538
|
+
* provider: 'azure_openai',
|
|
539
|
+
* model: 'gpt-4o',
|
|
540
|
+
* apiKey: 'your-azure-key',
|
|
541
|
+
* azureEndpoint: 'https://my-resource.openai.azure.com',
|
|
637
542
|
* variables: { topic: 'TypeScript' },
|
|
638
543
|
* });
|
|
639
544
|
*
|
|
@@ -643,14 +548,6 @@ declare class LlmProviderKeysResource {
|
|
|
643
548
|
* // Get models for a specific provider
|
|
644
549
|
* const openaiModels = await client.models.getByProvider('openai');
|
|
645
550
|
*
|
|
646
|
-
* // Manage LLM provider keys
|
|
647
|
-
* const { items } = await client.llmProviderKeys.list();
|
|
648
|
-
* const newKey = await client.llmProviderKeys.create({
|
|
649
|
-
* provider: 'openai',
|
|
650
|
-
* apiKey: 'sk-...',
|
|
651
|
-
* label: 'Production',
|
|
652
|
-
* });
|
|
653
|
-
*
|
|
654
551
|
* // With custom retry config
|
|
655
552
|
* const clientWithRetry = new SynovaCloudSdk('your-api-key', {
|
|
656
553
|
* retry: {
|
|
@@ -665,7 +562,6 @@ declare class SynovaCloudSdk {
|
|
|
665
562
|
readonly prompts: PromptsResource;
|
|
666
563
|
readonly models: ModelsResource;
|
|
667
564
|
readonly files: FilesResource;
|
|
668
|
-
readonly llmProviderKeys: LlmProviderKeysResource;
|
|
669
565
|
private readonly http;
|
|
670
566
|
/**
|
|
671
567
|
* Create a new Synova Cloud SDK client
|
|
@@ -737,4 +633,4 @@ declare class NetworkSynovaError extends SynovaError {
|
|
|
737
633
|
constructor(message: string, cause?: Error);
|
|
738
634
|
}
|
|
739
635
|
|
|
740
|
-
export { ApiSynovaError, AuthSynovaError, type
|
|
636
|
+
export { ApiSynovaError, AuthSynovaError, type ISynovaConfig, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, ServerSynovaError, SynovaCloudSdk, SynovaError, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaUsageType, TimeoutSynovaError };
|
package/dist/index.d.ts
CHANGED
|
@@ -102,8 +102,10 @@ interface ISynovaExecuteOptions {
|
|
|
102
102
|
provider: string;
|
|
103
103
|
/** LLM model to use (e.g., 'gpt-4o', 'claude-sonnet-4-20250514') */
|
|
104
104
|
model: string;
|
|
105
|
-
/**
|
|
106
|
-
|
|
105
|
+
/** Raw API key for the LLM provider */
|
|
106
|
+
apiKey?: string;
|
|
107
|
+
/** Azure OpenAI endpoint URL (required for azure_openai provider) */
|
|
108
|
+
azureEndpoint?: string;
|
|
107
109
|
/** Variables to substitute in prompt template */
|
|
108
110
|
variables?: Record<string, unknown>;
|
|
109
111
|
/** Previous messages for multi-turn conversation */
|
|
@@ -135,13 +137,38 @@ interface ISynovaExecutionUsage {
|
|
|
135
137
|
/** Prediction time in seconds (when type='time') */
|
|
136
138
|
predictTimeSeconds?: number;
|
|
137
139
|
}
|
|
140
|
+
interface ISynovaProviderResponse {
|
|
141
|
+
/** HTTP status code from the LLM provider */
|
|
142
|
+
statusCode?: number;
|
|
143
|
+
/** Error message from the LLM provider */
|
|
144
|
+
message?: string;
|
|
145
|
+
}
|
|
146
|
+
interface ISynovaExecutionErrorDetails {
|
|
147
|
+
/** Model used for the execution */
|
|
148
|
+
model?: string;
|
|
149
|
+
/** Last 5 characters of the API key used (for debugging) */
|
|
150
|
+
apiKeyHint?: string;
|
|
151
|
+
/** Prompt ID (if execution was via prompt) */
|
|
152
|
+
promptId?: string;
|
|
153
|
+
/** Prompt version (if execution was via prompt) */
|
|
154
|
+
promptVersion?: string;
|
|
155
|
+
/** Execution log ID for debugging */
|
|
156
|
+
executionLogId?: string;
|
|
157
|
+
/** Input tokens count (for CONTEXT_TOO_LONG errors) */
|
|
158
|
+
inputTokens?: number;
|
|
159
|
+
/** Model context window limit (for CONTEXT_TOO_LONG errors) */
|
|
160
|
+
contextLimit?: number;
|
|
161
|
+
}
|
|
138
162
|
interface ISynovaExecutionError {
|
|
139
163
|
code: string;
|
|
140
164
|
message: string;
|
|
141
165
|
provider?: string;
|
|
142
166
|
retryable: boolean;
|
|
143
167
|
retryAfterMs?: number;
|
|
144
|
-
|
|
168
|
+
/** Raw response from the LLM provider's API */
|
|
169
|
+
providerResponse?: ISynovaProviderResponse;
|
|
170
|
+
/** Our context details */
|
|
171
|
+
details?: ISynovaExecutionErrorDetails;
|
|
145
172
|
}
|
|
146
173
|
interface ISynovaFileThumbnails {
|
|
147
174
|
/** Small thumbnail URL (120px width) */
|
|
@@ -249,49 +276,6 @@ interface ISynovaUploadOptions {
|
|
|
249
276
|
/** Project ID to associate files with */
|
|
250
277
|
projectId: string;
|
|
251
278
|
}
|
|
252
|
-
type TSynovaLlmProvider = 'openai' | 'anthropic' | 'google' | 'azure_openai' | 'deepseek' | 'replicate' | 'xai' | 'openrouter';
|
|
253
|
-
interface ISynovaAzureConfig {
|
|
254
|
-
/** Azure OpenAI endpoint URL */
|
|
255
|
-
endpoint: string;
|
|
256
|
-
}
|
|
257
|
-
interface ISynovaLlmProviderKey {
|
|
258
|
-
/** Key ID */
|
|
259
|
-
id: string;
|
|
260
|
-
/** LLM provider */
|
|
261
|
-
provider: TSynovaLlmProvider;
|
|
262
|
-
/** Masked API key (last 4 characters visible) */
|
|
263
|
-
maskedKey: string;
|
|
264
|
-
/** Whether this is the default key for the provider */
|
|
265
|
-
isDefault: boolean;
|
|
266
|
-
/** Default model for this provider */
|
|
267
|
-
defaultModel?: string;
|
|
268
|
-
/** Azure OpenAI configuration */
|
|
269
|
-
azure?: ISynovaAzureConfig;
|
|
270
|
-
/** Optional label to identify this key */
|
|
271
|
-
label?: string;
|
|
272
|
-
/** Creation date (ISO 8601) */
|
|
273
|
-
createdAt: string;
|
|
274
|
-
/** Last update date (ISO 8601) */
|
|
275
|
-
updatedAt: string;
|
|
276
|
-
}
|
|
277
|
-
interface ISynovaLlmProviderKeyListResponse {
|
|
278
|
-
items: ISynovaLlmProviderKey[];
|
|
279
|
-
total: number;
|
|
280
|
-
}
|
|
281
|
-
interface ISynovaCreateLlmProviderKeyOptions {
|
|
282
|
-
/** LLM provider */
|
|
283
|
-
provider: TSynovaLlmProvider;
|
|
284
|
-
/** API key for the LLM provider */
|
|
285
|
-
apiKey: string;
|
|
286
|
-
/** Whether this is the default key for the provider */
|
|
287
|
-
isDefault?: boolean;
|
|
288
|
-
/** Default model for this provider */
|
|
289
|
-
defaultModel?: string;
|
|
290
|
-
/** Azure OpenAI configuration (required for azure_openai provider) */
|
|
291
|
-
azure?: ISynovaAzureConfig;
|
|
292
|
-
/** Optional label to identify this key */
|
|
293
|
-
label?: string;
|
|
294
|
-
}
|
|
295
279
|
interface IApiErrorResponse {
|
|
296
280
|
code: string;
|
|
297
281
|
httpCode: number;
|
|
@@ -529,95 +513,6 @@ declare class FilesResource {
|
|
|
529
513
|
upload(files: (File | Blob)[], options: ISynovaUploadOptions): Promise<ISynovaUploadResponse>;
|
|
530
514
|
}
|
|
531
515
|
|
|
532
|
-
declare class LlmProviderKeysResource {
|
|
533
|
-
private readonly http;
|
|
534
|
-
constructor(http: HttpClient);
|
|
535
|
-
/**
|
|
536
|
-
* List all LLM provider keys
|
|
537
|
-
*
|
|
538
|
-
* @returns List of LLM provider keys
|
|
539
|
-
*
|
|
540
|
-
* @example
|
|
541
|
-
* ```ts
|
|
542
|
-
* const { items, total } = await client.llmProviderKeys.list();
|
|
543
|
-
* console.log(`Found ${total} keys`);
|
|
544
|
-
* for (const key of items) {
|
|
545
|
-
* console.log(`${key.provider}: ${key.maskedKey} (default: ${key.isDefault})`);
|
|
546
|
-
* }
|
|
547
|
-
* ```
|
|
548
|
-
*/
|
|
549
|
-
list(): Promise<ISynovaLlmProviderKeyListResponse>;
|
|
550
|
-
/**
|
|
551
|
-
* Get an LLM provider key by ID
|
|
552
|
-
*
|
|
553
|
-
* @param id - Key ID (e.g., 'lpk_abc123')
|
|
554
|
-
* @returns LLM provider key details
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* const key = await client.llmProviderKeys.get('lpk_abc123');
|
|
559
|
-
* console.log(`Provider: ${key.provider}, Default: ${key.isDefault}`);
|
|
560
|
-
* ```
|
|
561
|
-
*/
|
|
562
|
-
get(id: string): Promise<ISynovaLlmProviderKey>;
|
|
563
|
-
/**
|
|
564
|
-
* Create a new LLM provider key
|
|
565
|
-
*
|
|
566
|
-
* The first key created for a provider will automatically be set as the default.
|
|
567
|
-
*
|
|
568
|
-
* @param options - Key creation options
|
|
569
|
-
* @returns Created LLM provider key
|
|
570
|
-
*
|
|
571
|
-
* @example
|
|
572
|
-
* ```ts
|
|
573
|
-
* // Create OpenAI key
|
|
574
|
-
* const key = await client.llmProviderKeys.create({
|
|
575
|
-
* provider: 'openai',
|
|
576
|
-
* apiKey: 'sk-...',
|
|
577
|
-
* label: 'Production Key',
|
|
578
|
-
* defaultModel: 'gpt-4o',
|
|
579
|
-
* });
|
|
580
|
-
*
|
|
581
|
-
* // Create Azure OpenAI key
|
|
582
|
-
* const azureKey = await client.llmProviderKeys.create({
|
|
583
|
-
* provider: 'azure_openai',
|
|
584
|
-
* apiKey: 'your-azure-key',
|
|
585
|
-
* azure: {
|
|
586
|
-
* endpoint: 'https://my-resource.openai.azure.com',
|
|
587
|
-
* },
|
|
588
|
-
* label: 'Azure Production',
|
|
589
|
-
* });
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
create(options: ISynovaCreateLlmProviderKeyOptions): Promise<ISynovaLlmProviderKey>;
|
|
593
|
-
/**
|
|
594
|
-
* Set an LLM provider key as the default for its provider
|
|
595
|
-
*
|
|
596
|
-
* The previous default key for this provider will be unset.
|
|
597
|
-
*
|
|
598
|
-
* @param id - Key ID to set as default
|
|
599
|
-
* @returns Updated LLM provider key
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* ```ts
|
|
603
|
-
* const key = await client.llmProviderKeys.setDefault('lpk_abc123');
|
|
604
|
-
* console.log(`${key.id} is now the default for ${key.provider}`);
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
setDefault(id: string): Promise<ISynovaLlmProviderKey>;
|
|
608
|
-
/**
|
|
609
|
-
* Delete an LLM provider key
|
|
610
|
-
*
|
|
611
|
-
* @param id - Key ID to delete
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
* ```ts
|
|
615
|
-
* await client.llmProviderKeys.delete('lpk_abc123');
|
|
616
|
-
* ```
|
|
617
|
-
*/
|
|
618
|
-
delete(id: string): Promise<void>;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
516
|
/**
|
|
622
517
|
* Synova Cloud SDK client
|
|
623
518
|
*
|
|
@@ -630,10 +525,20 @@ declare class LlmProviderKeysResource {
|
|
|
630
525
|
* // Get a prompt
|
|
631
526
|
* const prompt = await client.prompts.get('prm_abc123');
|
|
632
527
|
*
|
|
633
|
-
* // Execute a prompt
|
|
528
|
+
* // Execute a prompt with direct API key
|
|
634
529
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
635
530
|
* provider: 'openai',
|
|
636
531
|
* model: 'gpt-4o',
|
|
532
|
+
* apiKey: 'sk-...',
|
|
533
|
+
* variables: { topic: 'TypeScript' },
|
|
534
|
+
* });
|
|
535
|
+
*
|
|
536
|
+
* // Execute with Azure OpenAI
|
|
537
|
+
* const azureResult = await client.prompts.execute('prm_abc123', {
|
|
538
|
+
* provider: 'azure_openai',
|
|
539
|
+
* model: 'gpt-4o',
|
|
540
|
+
* apiKey: 'your-azure-key',
|
|
541
|
+
* azureEndpoint: 'https://my-resource.openai.azure.com',
|
|
637
542
|
* variables: { topic: 'TypeScript' },
|
|
638
543
|
* });
|
|
639
544
|
*
|
|
@@ -643,14 +548,6 @@ declare class LlmProviderKeysResource {
|
|
|
643
548
|
* // Get models for a specific provider
|
|
644
549
|
* const openaiModels = await client.models.getByProvider('openai');
|
|
645
550
|
*
|
|
646
|
-
* // Manage LLM provider keys
|
|
647
|
-
* const { items } = await client.llmProviderKeys.list();
|
|
648
|
-
* const newKey = await client.llmProviderKeys.create({
|
|
649
|
-
* provider: 'openai',
|
|
650
|
-
* apiKey: 'sk-...',
|
|
651
|
-
* label: 'Production',
|
|
652
|
-
* });
|
|
653
|
-
*
|
|
654
551
|
* // With custom retry config
|
|
655
552
|
* const clientWithRetry = new SynovaCloudSdk('your-api-key', {
|
|
656
553
|
* retry: {
|
|
@@ -665,7 +562,6 @@ declare class SynovaCloudSdk {
|
|
|
665
562
|
readonly prompts: PromptsResource;
|
|
666
563
|
readonly models: ModelsResource;
|
|
667
564
|
readonly files: FilesResource;
|
|
668
|
-
readonly llmProviderKeys: LlmProviderKeysResource;
|
|
669
565
|
private readonly http;
|
|
670
566
|
/**
|
|
671
567
|
* Create a new Synova Cloud SDK client
|
|
@@ -737,4 +633,4 @@ declare class NetworkSynovaError extends SynovaError {
|
|
|
737
633
|
constructor(message: string, cause?: Error);
|
|
738
634
|
}
|
|
739
635
|
|
|
740
|
-
export { ApiSynovaError, AuthSynovaError, type
|
|
636
|
+
export { ApiSynovaError, AuthSynovaError, type ISynovaConfig, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, ServerSynovaError, SynovaCloudSdk, SynovaError, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaUsageType, TimeoutSynovaError };
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var NetworkSynovaError = class extends SynovaError {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
// src/version.ts
|
|
74
|
-
var SDK_VERSION = "1.
|
|
74
|
+
var SDK_VERSION = "1.6.0" ;
|
|
75
75
|
|
|
76
76
|
// src/utils/http.ts
|
|
77
77
|
var HttpClient = class {
|
|
@@ -361,7 +361,8 @@ var PromptsResource = class {
|
|
|
361
361
|
provider: options.provider,
|
|
362
362
|
model: options.model
|
|
363
363
|
};
|
|
364
|
-
if (options.
|
|
364
|
+
if (options.apiKey !== void 0) body.apiKey = options.apiKey;
|
|
365
|
+
if (options.azureEndpoint !== void 0) body.azureEndpoint = options.azureEndpoint;
|
|
365
366
|
if (options.variables !== void 0) body.variables = options.variables;
|
|
366
367
|
if (options.messages !== void 0) body.messages = options.messages;
|
|
367
368
|
if (options.tag !== void 0) body.tag = options.tag;
|
|
@@ -400,7 +401,8 @@ var PromptsResource = class {
|
|
|
400
401
|
tag,
|
|
401
402
|
provider: options.provider,
|
|
402
403
|
model: options.model,
|
|
403
|
-
|
|
404
|
+
apiKey: options.apiKey,
|
|
405
|
+
azureEndpoint: options.azureEndpoint,
|
|
404
406
|
variables: options.variables,
|
|
405
407
|
messages: options.messages,
|
|
406
408
|
metadata: options.metadata,
|
|
@@ -433,7 +435,8 @@ var PromptsResource = class {
|
|
|
433
435
|
version,
|
|
434
436
|
provider: options.provider,
|
|
435
437
|
model: options.model,
|
|
436
|
-
|
|
438
|
+
apiKey: options.apiKey,
|
|
439
|
+
azureEndpoint: options.azureEndpoint,
|
|
437
440
|
variables: options.variables,
|
|
438
441
|
messages: options.messages,
|
|
439
442
|
metadata: options.metadata,
|
|
@@ -571,123 +574,6 @@ var FilesResource = class {
|
|
|
571
574
|
}
|
|
572
575
|
};
|
|
573
576
|
|
|
574
|
-
// src/resources/llm-provider-keys.ts
|
|
575
|
-
var LlmProviderKeysResource = class {
|
|
576
|
-
constructor(http) {
|
|
577
|
-
this.http = http;
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* List all LLM provider keys
|
|
581
|
-
*
|
|
582
|
-
* @returns List of LLM provider keys
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* ```ts
|
|
586
|
-
* const { items, total } = await client.llmProviderKeys.list();
|
|
587
|
-
* console.log(`Found ${total} keys`);
|
|
588
|
-
* for (const key of items) {
|
|
589
|
-
* console.log(`${key.provider}: ${key.maskedKey} (default: ${key.isDefault})`);
|
|
590
|
-
* }
|
|
591
|
-
* ```
|
|
592
|
-
*/
|
|
593
|
-
async list() {
|
|
594
|
-
return this.http.request({
|
|
595
|
-
method: "GET",
|
|
596
|
-
path: "/api/v1/llm-provider-keys"
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Get an LLM provider key by ID
|
|
601
|
-
*
|
|
602
|
-
* @param id - Key ID (e.g., 'lpk_abc123')
|
|
603
|
-
* @returns LLM provider key details
|
|
604
|
-
*
|
|
605
|
-
* @example
|
|
606
|
-
* ```ts
|
|
607
|
-
* const key = await client.llmProviderKeys.get('lpk_abc123');
|
|
608
|
-
* console.log(`Provider: ${key.provider}, Default: ${key.isDefault}`);
|
|
609
|
-
* ```
|
|
610
|
-
*/
|
|
611
|
-
async get(id) {
|
|
612
|
-
return this.http.request({
|
|
613
|
-
method: "GET",
|
|
614
|
-
path: `/api/v1/llm-provider-keys/${id}`
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Create a new LLM provider key
|
|
619
|
-
*
|
|
620
|
-
* The first key created for a provider will automatically be set as the default.
|
|
621
|
-
*
|
|
622
|
-
* @param options - Key creation options
|
|
623
|
-
* @returns Created LLM provider key
|
|
624
|
-
*
|
|
625
|
-
* @example
|
|
626
|
-
* ```ts
|
|
627
|
-
* // Create OpenAI key
|
|
628
|
-
* const key = await client.llmProviderKeys.create({
|
|
629
|
-
* provider: 'openai',
|
|
630
|
-
* apiKey: 'sk-...',
|
|
631
|
-
* label: 'Production Key',
|
|
632
|
-
* defaultModel: 'gpt-4o',
|
|
633
|
-
* });
|
|
634
|
-
*
|
|
635
|
-
* // Create Azure OpenAI key
|
|
636
|
-
* const azureKey = await client.llmProviderKeys.create({
|
|
637
|
-
* provider: 'azure_openai',
|
|
638
|
-
* apiKey: 'your-azure-key',
|
|
639
|
-
* azure: {
|
|
640
|
-
* endpoint: 'https://my-resource.openai.azure.com',
|
|
641
|
-
* },
|
|
642
|
-
* label: 'Azure Production',
|
|
643
|
-
* });
|
|
644
|
-
* ```
|
|
645
|
-
*/
|
|
646
|
-
async create(options) {
|
|
647
|
-
return this.http.request({
|
|
648
|
-
method: "POST",
|
|
649
|
-
path: "/api/v1/llm-provider-keys",
|
|
650
|
-
body: options
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Set an LLM provider key as the default for its provider
|
|
655
|
-
*
|
|
656
|
-
* The previous default key for this provider will be unset.
|
|
657
|
-
*
|
|
658
|
-
* @param id - Key ID to set as default
|
|
659
|
-
* @returns Updated LLM provider key
|
|
660
|
-
*
|
|
661
|
-
* @example
|
|
662
|
-
* ```ts
|
|
663
|
-
* const key = await client.llmProviderKeys.setDefault('lpk_abc123');
|
|
664
|
-
* console.log(`${key.id} is now the default for ${key.provider}`);
|
|
665
|
-
* ```
|
|
666
|
-
*/
|
|
667
|
-
async setDefault(id) {
|
|
668
|
-
return this.http.request({
|
|
669
|
-
method: "POST",
|
|
670
|
-
path: `/api/v1/llm-provider-keys/${id}/set-default`
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Delete an LLM provider key
|
|
675
|
-
*
|
|
676
|
-
* @param id - Key ID to delete
|
|
677
|
-
*
|
|
678
|
-
* @example
|
|
679
|
-
* ```ts
|
|
680
|
-
* await client.llmProviderKeys.delete('lpk_abc123');
|
|
681
|
-
* ```
|
|
682
|
-
*/
|
|
683
|
-
async delete(id) {
|
|
684
|
-
await this.http.request({
|
|
685
|
-
method: "DELETE",
|
|
686
|
-
path: `/api/v1/llm-provider-keys/${id}`
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
|
|
691
577
|
// src/client.ts
|
|
692
578
|
var DEFAULT_BASE_URL = "https://api.synova.cloud";
|
|
693
579
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -708,7 +594,6 @@ var SynovaCloudSdk = class {
|
|
|
708
594
|
prompts;
|
|
709
595
|
models;
|
|
710
596
|
files;
|
|
711
|
-
llmProviderKeys;
|
|
712
597
|
http;
|
|
713
598
|
/**
|
|
714
599
|
* Create a new Synova Cloud SDK client
|
|
@@ -737,7 +622,6 @@ var SynovaCloudSdk = class {
|
|
|
737
622
|
this.prompts = new PromptsResource(this.http);
|
|
738
623
|
this.models = new ModelsResource(this.http);
|
|
739
624
|
this.files = new FilesResource(this.http);
|
|
740
|
-
this.llmProviderKeys = new LlmProviderKeysResource(this.http);
|
|
741
625
|
}
|
|
742
626
|
};
|
|
743
627
|
|