krisspy-ai 1.1.17

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 ADDED
@@ -0,0 +1,432 @@
1
+ # krisspy-ai
2
+
3
+ Official library for building AI agents on the **Krisspy** platform.
4
+
5
+ ## What is krisspy-ai?
6
+
7
+ `krisspy-ai` enables you to create **custom agents** using the [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk), while making it compatible with many models through an integrated proxy system.
8
+
9
+ ### Key Features
10
+
11
+ - **Multi-providers**: Anthropic, OpenAI, Gemini, AWS Bedrock, Azure AI, Z.AI
12
+ - **Advanced reasoning**: Extended thinking supported across all providers
13
+ - **Code execution**: Agents can execute code in real-time
14
+ - **Sub-agents**: Build multi-agent architectures
15
+ - **Skills**: Use Anthropic Skills (Office files, etc.)
16
+ - **MCP**: Connect external tools via MCP protocol
17
+ - **GenAI Services**: Image generation, video generation, speech-to-text, text-to-speech
18
+
19
+ All of this **without worrying about the underlying model** - the proxy automatically translates requests.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install krisspy-ai
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ### With Anthropic (direct)
30
+
31
+ ```typescript
32
+ import { query } from 'krisspy-ai';
33
+
34
+ for await (const event of query({
35
+ prompt: 'Analyze this code and suggest improvements',
36
+ options: {
37
+ provider: 'anthropic',
38
+ apiKey: 'sk-ant-...',
39
+ model: 'sonnet' // haiku, sonnet, opus
40
+ }
41
+ })) {
42
+ console.log(event);
43
+ }
44
+ ```
45
+
46
+ ### With AWS Bedrock
47
+
48
+ ```typescript
49
+ import { query } from 'krisspy-ai';
50
+
51
+ for await (const event of query({
52
+ prompt: 'Create an optimized sorting function',
53
+ options: {
54
+ provider: 'bedrock',
55
+ accessKeyId: 'AKIA...',
56
+ secretAccessKey: '...',
57
+ region: 'us-west-2',
58
+ model: 'sonnet' // haiku, haiku-4.5, sonnet, sonnet-4, sonnet-4.5, opus, opus-4, opus-4.5
59
+ }
60
+ })) {
61
+ console.log(event);
62
+ }
63
+ ```
64
+
65
+ ### With OpenAI (via proxy)
66
+
67
+ ```typescript
68
+ import { query } from 'krisspy-ai';
69
+
70
+ for await (const event of query({
71
+ prompt: 'Explain design patterns to me',
72
+ options: {
73
+ provider: 'openai',
74
+ apiKey: 'sk-...',
75
+ model: 'gpt-4o'
76
+ }
77
+ })) {
78
+ console.log(event);
79
+ }
80
+ ```
81
+
82
+ ## Supported Providers
83
+
84
+ | Provider | Description | Models |
85
+ |----------|-------------|--------|
86
+ | `anthropic` | Direct Anthropic API | haiku, sonnet, opus |
87
+ | `bedrock` | AWS Bedrock (Claude) | haiku, sonnet, opus + 4/4.5 versions |
88
+ | `azure` | Azure AI Foundry | gpt-4o, gpt-5.2 |
89
+ | `openai` | OpenAI via proxy | gpt-4o, gpt-5.2, o1, o3 |
90
+ | `gemini` | Google Gemini via proxy | gemini-2.5-pro, gemini-2.5-flash |
91
+ | `zai` | Z.AI via proxy | glm-4.7 |
92
+ | `zai_direct` | Z.AI Anthropic endpoint | haiku, sonnet, opus |
93
+
94
+ ## Bedrock Models
95
+
96
+ | Alias | Bedrock Model ID |
97
+ |-------|------------------|
98
+ | `haiku` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` |
99
+ | `haiku-4.5` | `global.anthropic.claude-haiku-4-5-20251001-v1:0` |
100
+ | `sonnet` | `global.anthropic.claude-sonnet-4-20250514-v1:0` |
101
+ | `sonnet-4` | `global.anthropic.claude-sonnet-4-20250514-v1:0` |
102
+ | `sonnet-4.5` | `us.anthropic.claude-sonnet-4-5-20250929-v1:0` |
103
+ | `opus` | `global.anthropic.claude-opus-4-5-20251101-v1:0` |
104
+ | `opus-4` | `global.anthropic.claude-opus-4-20250514-v1:0` |
105
+ | `opus-4.5` | `global.anthropic.claude-opus-4-5-20251101-v1:0` |
106
+
107
+ ---
108
+
109
+ ## GenAI Services
110
+
111
+ `krisspy-ai` includes generative AI services for image, video, and audio. These services work with both **OpenAI** and **Azure OpenAI**.
112
+
113
+ ### Image Generation
114
+
115
+ Generate images using GPT-Image-1 (OpenAI) or Azure DALL-E/GPT-Image.
116
+
117
+ ```typescript
118
+ import { generateImage } from 'krisspy-ai';
119
+
120
+ // With OpenAI
121
+ const result = await generateImage({
122
+ service: 'openai',
123
+ apiKey: 'sk-...',
124
+ deploymentName: 'gpt-image-1', // or 'dall-e-3'
125
+ prompt: 'A cute baby polar bear playing in the snow',
126
+ size: '1024x1024', // '1024x1024', '1792x1024', '1024x1792'
127
+ });
128
+
129
+ console.log(result.data[0].url);
130
+
131
+ // With Azure OpenAI
132
+ const azureResult = await generateImage({
133
+ service: 'azure',
134
+ apiKey: 'your-azure-key',
135
+ baseUrl: 'https://your-resource.openai.azure.com',
136
+ deploymentName: 'gpt-image-1',
137
+ apiVersion: '2024-02-15-preview',
138
+ prompt: 'A futuristic city at sunset',
139
+ size: '1792x1024',
140
+ quality: 'hd',
141
+ });
142
+ ```
143
+
144
+ ### Video Generation (Sora)
145
+
146
+ Generate videos using OpenAI Sora or Azure Sora.
147
+
148
+ ```typescript
149
+ import { generateVideo } from 'krisspy-ai';
150
+
151
+ // Async generator with status updates
152
+ for await (const event of generateVideo({
153
+ service: 'openai',
154
+ apiKey: 'sk-...',
155
+ deploymentName: 'sora',
156
+ prompt: 'Woolly mammoths walking through a snowy tundra',
157
+ duration: 5, // seconds
158
+ width: 1920,
159
+ height: 1080,
160
+ })) {
161
+ if (event.type === 'status') {
162
+ console.log(`Status: ${event.status.status}, Progress: ${event.status.progress}%`);
163
+ } else if (event.type === 'result') {
164
+ console.log(`Video ready: ${event.data.generations[0].url}`);
165
+ }
166
+ }
167
+
168
+ // With Azure OpenAI
169
+ for await (const event of generateVideo({
170
+ service: 'azure',
171
+ apiKey: 'your-azure-key',
172
+ baseUrl: 'https://your-resource.openai.azure.com',
173
+ deploymentName: 'sora-2',
174
+ prompt: 'A drone flying over mountains at sunrise',
175
+ duration: 10,
176
+ })) {
177
+ // Same event handling
178
+ }
179
+ ```
180
+
181
+ ### Speech-to-Text (Transcription)
182
+
183
+ Transcribe audio using Whisper or GPT-4o-transcribe.
184
+
185
+ ```typescript
186
+ import { transcribe } from 'krisspy-ai';
187
+ import fs from 'fs';
188
+
189
+ const audioBuffer = fs.readFileSync('audio.mp3');
190
+
191
+ // With OpenAI
192
+ const result = await transcribe({
193
+ service: 'openai',
194
+ apiKey: 'sk-...',
195
+ deploymentName: 'whisper-1', // or 'gpt-4o-transcribe'
196
+ audio: audioBuffer,
197
+ language: 'en',
198
+ responseFormat: 'verbose_json',
199
+ timestampGranularities: ['word', 'segment'],
200
+ });
201
+
202
+ console.log(result.text);
203
+ console.log(result.words); // Word-level timestamps
204
+ console.log(result.segments); // Segment-level timestamps
205
+
206
+ // With Azure OpenAI
207
+ const azureResult = await transcribe({
208
+ service: 'azure',
209
+ apiKey: 'your-azure-key',
210
+ baseUrl: 'https://your-resource.openai.azure.com',
211
+ deploymentName: 'whisper',
212
+ apiVersion: '2025-03-01-preview',
213
+ audio: audioBuffer,
214
+ });
215
+
216
+ // With speaker diarization (Azure gpt-4o-transcribe-diarize)
217
+ const diarizedResult = await transcribe({
218
+ service: 'azure',
219
+ apiKey: 'your-azure-key',
220
+ baseUrl: 'https://your-resource.openai.azure.com',
221
+ deploymentName: 'gpt-4o-transcribe-diarize',
222
+ apiVersion: '2025-03-01-preview',
223
+ audio: audioBuffer,
224
+ });
225
+
226
+ console.log(diarizedResult.utterances); // Speaker-separated segments
227
+ ```
228
+
229
+ ### Text-to-Speech (TTS)
230
+
231
+ Convert text to speech using TTS-1, TTS-1-HD, or GPT-4o-mini-tts.
232
+
233
+ ```typescript
234
+ import { synthesize } from 'krisspy-ai';
235
+ import fs from 'fs';
236
+
237
+ // With OpenAI
238
+ const result = await synthesize({
239
+ service: 'openai',
240
+ apiKey: 'sk-...',
241
+ deploymentName: 'tts-1', // 'tts-1', 'tts-1-hd', 'gpt-4o-mini-tts'
242
+ input: 'Hello! Welcome to krisspy-ai.',
243
+ voice: 'nova', // alloy, ash, coral, echo, fable, nova, onyx, sage, shimmer
244
+ speed: 1.0, // 0.25 to 4.0
245
+ responseFormat: 'mp3',
246
+ });
247
+
248
+ fs.writeFileSync('output.mp3', result.audio);
249
+
250
+ // With Azure OpenAI (only supports: alloy, echo, fable, nova, onyx, shimmer)
251
+ const azureResult = await synthesize({
252
+ service: 'azure',
253
+ apiKey: 'your-azure-key',
254
+ baseUrl: 'https://your-resource.openai.azure.com',
255
+ deploymentName: 'tts',
256
+ apiVersion: '2025-03-01-preview',
257
+ input: 'Hello from Azure!',
258
+ voice: 'nova',
259
+ });
260
+
261
+ // With voice styling (gpt-4o-mini-tts only)
262
+ const styledResult = await synthesize({
263
+ service: 'openai',
264
+ apiKey: 'sk-...',
265
+ deploymentName: 'gpt-4o-mini-tts',
266
+ input: 'This is exciting news!',
267
+ voice: 'coral',
268
+ instructions: 'Speak with enthusiasm and energy',
269
+ });
270
+ ```
271
+
272
+ ### GenAI Service Options
273
+
274
+ #### Image Generation Options
275
+
276
+ | Option | Type | Description |
277
+ |--------|------|-------------|
278
+ | `service` | `'openai' \| 'azure'` | Provider to use |
279
+ | `apiKey` | `string` | API key |
280
+ | `baseUrl` | `string` | Base URL (required for Azure) |
281
+ | `deploymentName` | `string` | Model/deployment name |
282
+ | `prompt` | `string` | Image description |
283
+ | `size` | `string` | `'1024x1024'`, `'1792x1024'`, `'1024x1792'` |
284
+ | `quality` | `string` | `'standard'` or `'hd'` |
285
+ | `n` | `number` | Number of images (1-10) |
286
+
287
+ #### Video Generation Options
288
+
289
+ | Option | Type | Description |
290
+ |--------|------|-------------|
291
+ | `service` | `'openai' \| 'azure'` | Provider to use |
292
+ | `apiKey` | `string` | API key |
293
+ | `baseUrl` | `string` | Base URL (required for Azure) |
294
+ | `deploymentName` | `string` | Model/deployment name |
295
+ | `prompt` | `string` | Video description |
296
+ | `duration` | `number` | Duration in seconds |
297
+ | `width` | `number` | Video width (default: 1920) |
298
+ | `height` | `number` | Video height (default: 1080) |
299
+ | `nVariants` | `number` | Number of variants |
300
+
301
+ #### Transcription Options
302
+
303
+ | Option | Type | Description |
304
+ |--------|------|-------------|
305
+ | `service` | `'openai' \| 'azure'` | Provider to use |
306
+ | `apiKey` | `string` | API key |
307
+ | `baseUrl` | `string` | Base URL (required for Azure) |
308
+ | `deploymentName` | `string` | Model/deployment name |
309
+ | `audio` | `Buffer \| string` | Audio data or file path |
310
+ | `language` | `string` | ISO-639-1 language code |
311
+ | `responseFormat` | `string` | `'json'`, `'text'`, `'srt'`, `'vtt'`, `'verbose_json'` |
312
+ | `timestampGranularities` | `string[]` | `['word']`, `['segment']`, or both |
313
+
314
+ #### TTS Options
315
+
316
+ | Option | Type | Description |
317
+ |--------|------|-------------|
318
+ | `service` | `'openai' \| 'azure'` | Provider to use |
319
+ | `apiKey` | `string` | API key |
320
+ | `baseUrl` | `string` | Base URL (required for Azure) |
321
+ | `deploymentName` | `string` | Model/deployment name |
322
+ | `input` | `string` | Text to synthesize (max 4096 chars) |
323
+ | `voice` | `string` | Voice name |
324
+ | `speed` | `number` | Speed (0.25 to 4.0) |
325
+ | `responseFormat` | `string` | `'mp3'`, `'opus'`, `'aac'`, `'flac'`, `'wav'`, `'pcm'` |
326
+ | `instructions` | `string` | Voice styling (gpt-4o-mini-tts only) |
327
+
328
+ ---
329
+
330
+ ## Advanced Options
331
+
332
+ ```typescript
333
+ const options = {
334
+ // Provider
335
+ provider: 'anthropic',
336
+ apiKey: 'sk-ant-...',
337
+ model: 'sonnet',
338
+ baseUrl: 'https://api.anthropic.com',
339
+
340
+ // Extended Thinking
341
+ maxThinkingTokens: 10000,
342
+
343
+ // MCP Servers
344
+ mcpServers: {
345
+ filesystem: {
346
+ command: 'npx',
347
+ args: ['-y', '@anthropic-ai/mcp-server-filesystem', '/path']
348
+ },
349
+ http_server: {
350
+ type: 'http',
351
+ url: 'http://localhost:3001/mcp'
352
+ }
353
+ },
354
+
355
+ // Skills (Office files)
356
+ betas: ['skills-2025-10-02'],
357
+
358
+ // Attachments
359
+ attachments: {
360
+ images: [{ type: 'url', url: 'https://...' }],
361
+ files: [{ type: 'pdf', media_type: 'application/pdf', data: 'base64...' }]
362
+ },
363
+
364
+ // Execution limits
365
+ maxTurns: 50,
366
+ maxBudgetUsd: 5.00,
367
+
368
+ // Tools
369
+ allowedTools: ['Read', 'Edit', 'Bash', 'WebSearch'],
370
+ permissionMode: 'acceptEdits',
371
+
372
+ // AWS Bedrock
373
+ accessKeyId: 'AKIA...',
374
+ secretAccessKey: '...',
375
+ region: 'us-west-2',
376
+
377
+ // Azure AI
378
+ deploymentName: 'my-deployment',
379
+ apiVersion: '2024-02-15-preview'
380
+ };
381
+ ```
382
+
383
+ ## Architecture
384
+
385
+ ```
386
+ ┌─────────────────────────────────────────────────────────────┐
387
+ │ krisspy-ai │
388
+ ├─────────────────────────────────────────────────────────────┤
389
+ │ │
390
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
391
+ │ │ Anthropic │ │ Bedrock │ │ Azure │ │
392
+ │ │ (direct) │ │ (native) │ │ (proxy) │ │
393
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
394
+ │ │
395
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
396
+ │ │ OpenAI │ │ Gemini │ │ Z.AI │ │
397
+ │ │ (proxy) │ │ (proxy) │ │ (proxy) │ │
398
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
399
+ │ │
400
+ │ ┌──────────────────┐ │
401
+ │ │ Claude Agent │ │
402
+ │ │ SDK │ │
403
+ │ └──────────────────┘ │
404
+ │ │ │
405
+ │ ┌──────────────────┼──────────────────┐ │
406
+ │ ▼ ▼ ▼ │
407
+ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
408
+ │ │ Reasoning │ │ Code │ │ MCP │ │
409
+ │ │ │ │ Execution │ │ Tools │ │
410
+ │ └────────────┘ └────────────┘ └────────────┘ │
411
+ │ │
412
+ │ ┌─────────────────────────────────────────────────────┐ │
413
+ │ │ GenAI Services │ │
414
+ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌────────┐ │ │
415
+ │ │ │ Image │ │ Video │ │ STT │ │ TTS │ │ │
416
+ │ │ │ (DALL-E)│ │ (Sora) │ │(Whisper)│ │ │ │ │
417
+ │ │ └─────────┘ └─────────┘ └─────────┘ └────────┘ │ │
418
+ │ │ OpenAI | Azure OpenAI │ │
419
+ │ └─────────────────────────────────────────────────────┘ │
420
+ │ │
421
+ └─────────────────────────────────────────────────────────────┘
422
+ ```
423
+
424
+ ## License
425
+
426
+ ISC
427
+
428
+ ## Links
429
+
430
+ - [Krisspy Platform](https://krisspy.ai)
431
+ - [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk)
432
+ - [API Documentation](https://docs.krisspy.ai)