@revenium/openai 1.0.11 → 1.0.12
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/.env.example +20 -0
- package/CHANGELOG.md +21 -47
- package/README.md +141 -690
- package/dist/cjs/core/config/loader.js +1 -1
- package/dist/cjs/core/config/loader.js.map +1 -1
- package/dist/cjs/core/tracking/api-client.js +1 -1
- package/dist/cjs/core/tracking/api-client.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/url-builder.js +32 -7
- package/dist/cjs/utils/url-builder.js.map +1 -1
- package/dist/esm/core/config/loader.js +1 -1
- package/dist/esm/core/config/loader.js.map +1 -1
- package/dist/esm/core/tracking/api-client.js +1 -1
- package/dist/esm/core/tracking/api-client.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/url-builder.js +32 -7
- package/dist/esm/utils/url-builder.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/url-builder.d.ts +11 -3
- package/dist/types/utils/url-builder.d.ts.map +1 -1
- package/examples/README.md +250 -254
- package/examples/azure-basic.ts +25 -13
- package/examples/azure-responses-basic.ts +36 -7
- package/examples/azure-responses-streaming.ts +36 -7
- package/examples/azure-streaming.ts +40 -19
- package/examples/getting_started.ts +54 -0
- package/examples/openai-basic.ts +39 -17
- package/examples/openai-function-calling.ts +259 -0
- package/examples/openai-responses-basic.ts +36 -7
- package/examples/openai-responses-streaming.ts +36 -7
- package/examples/openai-streaming.ts +24 -13
- package/examples/openai-vision.ts +289 -0
- package/package.json +3 -9
- package/src/core/config/azure-config.ts +72 -0
- package/src/core/config/index.ts +23 -0
- package/src/core/config/loader.ts +66 -0
- package/src/core/config/manager.ts +94 -0
- package/src/core/config/validator.ts +89 -0
- package/src/core/providers/detector.ts +159 -0
- package/src/core/providers/index.ts +16 -0
- package/src/core/tracking/api-client.ts +78 -0
- package/src/core/tracking/index.ts +21 -0
- package/src/core/tracking/payload-builder.ts +132 -0
- package/src/core/tracking/usage-tracker.ts +189 -0
- package/src/core/wrapper/index.ts +9 -0
- package/src/core/wrapper/instance-patcher.ts +288 -0
- package/src/core/wrapper/request-handler.ts +423 -0
- package/src/core/wrapper/stream-wrapper.ts +100 -0
- package/src/index.ts +336 -0
- package/src/types/function-parameters.ts +251 -0
- package/src/types/index.ts +313 -0
- package/src/types/openai-augmentation.ts +233 -0
- package/src/types/responses-api.ts +308 -0
- package/src/utils/azure-model-resolver.ts +220 -0
- package/src/utils/constants.ts +21 -0
- package/src/utils/error-handler.ts +251 -0
- package/src/utils/metadata-builder.ts +219 -0
- package/src/utils/provider-detection.ts +257 -0
- package/src/utils/request-handler-factory.ts +285 -0
- package/src/utils/stop-reason-mapper.ts +74 -0
- package/src/utils/type-guards.ts +202 -0
- package/src/utils/url-builder.ts +68 -0
package/.env.example
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Revenium OpenAI Middleware Configuration
|
|
2
|
+
# Copy this file to .env and fill in your actual values
|
|
3
|
+
|
|
4
|
+
# Required: Your Revenium API key (starts with hak_)
|
|
5
|
+
REVENIUM_METERING_API_KEY=hak_your_revenium_api_key_here
|
|
6
|
+
|
|
7
|
+
# Optional: Revenium API base URL (defaults to https://api.revenium.io)
|
|
8
|
+
#REVENIUM_METERING_BASE_URL=https://api.revenium.io
|
|
9
|
+
|
|
10
|
+
# Required: Your OpenAI API key (starts with sk-)
|
|
11
|
+
OPENAI_API_KEY=sk_your_openai_api_key_here
|
|
12
|
+
|
|
13
|
+
# Optional: Your Azure OpenAI configuration (for Azure testing)
|
|
14
|
+
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/
|
|
15
|
+
AZURE_OPENAI_API_KEY=your-azure-openai-api-key-here
|
|
16
|
+
AZURE_OPENAI_DEPLOYMENT=your-deployment-name-here
|
|
17
|
+
AZURE_OPENAI_API_VERSION=2024-12-01-preview
|
|
18
|
+
|
|
19
|
+
# Optional: Enable debug logging
|
|
20
|
+
REVENIUM_DEBUG=false
|
package/CHANGELOG.md
CHANGED
|
@@ -5,73 +5,47 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.12] - 2025-10-30
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Improved documentation structure and Getting Started tutorial
|
|
12
|
+
- Enhanced package distribution to include TypeScript source files
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Repository configuration updates
|
|
16
|
+
|
|
8
17
|
## [1.0.11] - 2025-10-21
|
|
9
18
|
|
|
10
19
|
### Added
|
|
11
|
-
- Examples now included in npm package
|
|
12
|
-
-
|
|
13
|
-
- Step 4: Protect Your API Keys - Security best practices in main README
|
|
14
|
-
- TypeScript and JavaScript examples for getting started
|
|
20
|
+
- Examples now included in npm package
|
|
21
|
+
- Comprehensive examples documentation
|
|
15
22
|
|
|
16
23
|
### Changed
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- Improved README structure with enhanced security guidance
|
|
20
|
-
|
|
21
|
-
### Security
|
|
22
|
-
- Added `.gitignore` best practices to protect API keys
|
|
23
|
-
- Enhanced environment variable security documentation
|
|
24
|
+
- Updated API endpoint configuration
|
|
25
|
+
- Improved documentation structure
|
|
24
26
|
|
|
25
27
|
## [1.0.10] - 2025-10-17
|
|
26
28
|
|
|
27
29
|
### Added
|
|
28
|
-
- Support for OpenAI Responses API
|
|
29
|
-
- New example files for Responses API with Azure and standard OpenAI
|
|
30
|
-
- Enhanced TypeScript type definitions for Responses API
|
|
30
|
+
- Support for OpenAI Responses API
|
|
31
31
|
|
|
32
32
|
### Changed
|
|
33
|
-
-
|
|
34
|
-
- Improved examples structure and organization
|
|
35
|
-
- Package maintenance and stability improvements
|
|
33
|
+
- Enhanced documentation and examples
|
|
36
34
|
|
|
37
35
|
## [1.0.9] - 2025-10-16
|
|
38
36
|
|
|
39
37
|
### Changed
|
|
40
|
-
-
|
|
41
|
-
- Enhanced error handling and logging
|
|
38
|
+
- Bug fixes and stability improvements
|
|
42
39
|
|
|
43
40
|
## [1.0.8] - 2025-10-15
|
|
44
41
|
|
|
45
42
|
### Added
|
|
46
|
-
- Initial release
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- Support for function/tool calling
|
|
51
|
-
- Automatic metadata collection and forwarding
|
|
52
|
-
- Azure OpenAI support with automatic detection
|
|
53
|
-
- Full TypeScript support with native type integration
|
|
54
|
-
- Zero configuration setup from environment variables
|
|
55
|
-
|
|
56
|
-
### Changed
|
|
57
|
-
- Package name migrated to scoped format (@revenium/openai)
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Package Migration Notice
|
|
62
|
-
|
|
63
|
-
This package was previously published as `revenium-middleware-openai-node` up to v1.1.0.
|
|
64
|
-
|
|
65
|
-
Starting with v1.0.8, the package has been migrated to the scoped format `@revenium/openai`.
|
|
66
|
-
|
|
67
|
-
The old package has been deprecated with a notice directing users to the new scoped package.
|
|
68
|
-
|
|
69
|
-
To upgrade:
|
|
70
|
-
```bash
|
|
71
|
-
npm uninstall revenium-middleware-openai-node
|
|
72
|
-
npm install @revenium/openai
|
|
73
|
-
```
|
|
43
|
+
- Initial release with OpenAI usage tracking
|
|
44
|
+
- Support for streaming responses and function calling
|
|
45
|
+
- Azure OpenAI support
|
|
46
|
+
- TypeScript support with native type integration
|
|
74
47
|
|
|
48
|
+
[1.0.12]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.12
|
|
75
49
|
[1.0.11]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.11
|
|
76
50
|
[1.0.10]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.10
|
|
77
51
|
[1.0.9]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.9
|