@mariozechner/pi-ai 0.5.23 → 0.5.24
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 +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -427,6 +427,25 @@ if (model) {
|
|
|
427
427
|
}
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
+
## Browser Usage
|
|
431
|
+
|
|
432
|
+
The library supports browser environments. You must pass the API key explicitly since environment variables are not available in browsers:
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
import { createLLM } from '@mariozechner/pi-ai';
|
|
436
|
+
|
|
437
|
+
// API key must be passed explicitly in browser
|
|
438
|
+
const llm = createLLM('anthropic', 'claude-3-5-haiku-20241022', {
|
|
439
|
+
apiKey: 'your-api-key'
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const response = await llm.generate({
|
|
443
|
+
messages: [{ role: 'user', content: 'Hello!' }]
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
> **Security Warning**: Exposing API keys in frontend code is dangerous. Anyone can extract and abuse your keys. Only use this approach for internal tools or demos. For production applications, use a backend proxy that keeps your API keys secure.
|
|
448
|
+
|
|
430
449
|
## Environment Variables
|
|
431
450
|
|
|
432
451
|
Set these environment variables to use `createLLM` without passing API keys:
|