@revenium/openai 1.0.11 → 1.0.13
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 +47 -47
- package/README.md +121 -964
- package/dist/cjs/core/config/loader.js +1 -1
- package/dist/cjs/core/config/loader.js.map +1 -1
- package/dist/cjs/core/config/manager.js +2 -1
- package/dist/cjs/core/config/manager.js.map +1 -1
- package/dist/cjs/core/providers/detector.js +3 -3
- package/dist/cjs/core/providers/detector.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/core/tracking/payload-builder.js +17 -12
- package/dist/cjs/core/tracking/payload-builder.js.map +1 -1
- package/dist/cjs/index.js +23 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/metadata-builder.js +12 -5
- package/dist/cjs/utils/metadata-builder.js.map +1 -1
- package/dist/cjs/utils/stop-reason-mapper.js +4 -0
- package/dist/cjs/utils/stop-reason-mapper.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/config/manager.js +2 -1
- package/dist/esm/core/config/manager.js.map +1 -1
- package/dist/esm/core/providers/detector.js +3 -3
- package/dist/esm/core/providers/detector.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/core/tracking/payload-builder.js +17 -12
- package/dist/esm/core/tracking/payload-builder.js.map +1 -1
- package/dist/esm/index.js +22 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/metadata-builder.js +12 -5
- package/dist/esm/utils/metadata-builder.js.map +1 -1
- package/dist/esm/utils/stop-reason-mapper.js +4 -0
- package/dist/esm/utils/stop-reason-mapper.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/core/config/manager.d.ts.map +1 -1
- package/dist/types/core/tracking/payload-builder.d.ts.map +1 -1
- package/dist/types/index.d.ts +23 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +9 -13
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/openai-augmentation.d.ts +1 -2
- package/dist/types/types/openai-augmentation.d.ts.map +1 -1
- package/dist/types/utils/metadata-builder.d.ts +2 -1
- package/dist/types/utils/metadata-builder.d.ts.map +1 -1
- package/dist/types/utils/stop-reason-mapper.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 +213 -255
- package/examples/azure-basic.ts +26 -14
- package/examples/azure-responses-basic.ts +39 -10
- package/examples/azure-responses-streaming.ts +39 -10
- package/examples/azure-streaming.ts +41 -20
- 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 +38 -9
- package/examples/openai-responses-streaming.ts +38 -9
- 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 +95 -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 +137 -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 +360 -0
- package/src/types/function-parameters.ts +251 -0
- package/src/types/index.ts +310 -0
- package/src/types/openai-augmentation.ts +232 -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 +228 -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 +78 -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.ai)
|
|
8
|
+
#REVENIUM_METERING_BASE_URL=https://api.revenium.ai
|
|
9
|
+
|
|
10
|
+
# Required: Your OpenAI API key (starts with sk-)
|
|
11
|
+
OPENAI_API_KEY=sk_your_openai_api_key_here
|
|
12
|
+
|
|
13
|
+
# Optional: Azure OpenAI configuration (uncomment if using Azure)
|
|
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=true
|
package/CHANGELOG.md
CHANGED
|
@@ -5,73 +5,73 @@ 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.
|
|
8
|
+
## [1.0.13] - 2025-11-06
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- TypeScript and JavaScript examples for getting started
|
|
11
|
+
- configure() function for manual configuration (simpler alias for initializeRevenium)
|
|
12
|
+
- Support for COST_LIMIT and COMPLETION_LIMIT stop reasons
|
|
13
|
+
- Support for all 7 operationType enum values (CHAT, GENERATE, EMBED, CLASSIFY, SUMMARIZE, TRANSLATE, OTHER)
|
|
15
14
|
|
|
16
15
|
### Changed
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- Improved
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
16
|
+
- **BREAKING:** responseQualityScore now uses 0.0-1.0 scale (was 0-100) per updated API specification
|
|
17
|
+
- API endpoint updated from api.revenium.io to api.revenium.ai (new production domain)
|
|
18
|
+
- Improved API compliance with proper enum values and field casing
|
|
19
|
+
- Enhanced token counting accuracy for cache operations
|
|
20
|
+
- Email addresses now masked in debug logs for PII protection
|
|
21
|
+
- All examples updated to use 0.0-1.0 scale for responseQualityScore
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- Improved documentation accuracy and removed deprecated configuration options
|
|
25
|
+
- config.debug property now properly enables debug logging
|
|
26
|
+
- Manual configuration example now includes required patchOpenAIInstance call
|
|
27
|
+
- Updated OpenAI version requirement to match peer dependency (v5.0.0+)
|
|
28
|
+
- Enhanced metadata validation for responseQualityScore scale
|
|
29
|
+
- Improved provider detection fallback handling
|
|
30
|
+
- Fixed cache token reporting for embeddings API
|
|
31
|
+
- reasoningTokenCount now correctly optional based on provider support
|
|
32
|
+
|
|
33
|
+
## [1.0.12] - 2025-10-30
|
|
24
34
|
|
|
25
|
-
|
|
35
|
+
### Changed
|
|
36
|
+
- Improved documentation structure and Getting Started tutorial
|
|
37
|
+
- Enhanced package distribution to include TypeScript source files
|
|
26
38
|
|
|
27
|
-
###
|
|
28
|
-
-
|
|
29
|
-
- New example files for Responses API with Azure and standard OpenAI
|
|
30
|
-
- Enhanced TypeScript type definitions for Responses API
|
|
39
|
+
### Fixed
|
|
40
|
+
- Repository configuration updates
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
- README documentation significantly expanded with step-by-step guides
|
|
34
|
-
- Improved examples structure and organization
|
|
35
|
-
- Package maintenance and stability improvements
|
|
42
|
+
## [1.0.11] - 2025-10-21
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
### Added
|
|
45
|
+
- Examples now included in npm package
|
|
46
|
+
- Comprehensive examples documentation
|
|
38
47
|
|
|
39
48
|
### Changed
|
|
40
|
-
-
|
|
41
|
-
-
|
|
49
|
+
- Updated API endpoint configuration
|
|
50
|
+
- Improved documentation structure
|
|
42
51
|
|
|
43
|
-
## [1.0.
|
|
52
|
+
## [1.0.10] - 2025-10-17
|
|
44
53
|
|
|
45
54
|
### Added
|
|
46
|
-
-
|
|
47
|
-
- Migration from revenium-middleware-openai-node to @revenium/openai
|
|
48
|
-
- Transparent OpenAI API usage tracking middleware
|
|
49
|
-
- Support for streaming responses
|
|
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
|
+
- Support for OpenAI Responses API
|
|
55
56
|
|
|
56
57
|
### Changed
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Package Migration Notice
|
|
58
|
+
- Enhanced documentation and examples
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
## [1.0.9] - 2025-10-16
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
### Changed
|
|
63
|
+
- Bug fixes and stability improvements
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
## [1.0.8] - 2025-10-15
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
### Added
|
|
68
|
+
- Initial release with OpenAI usage tracking
|
|
69
|
+
- Support for streaming responses and function calling
|
|
70
|
+
- Azure OpenAI support
|
|
71
|
+
- TypeScript support with native type integration
|
|
74
72
|
|
|
73
|
+
[1.0.13]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.13
|
|
74
|
+
[1.0.12]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.12
|
|
75
75
|
[1.0.11]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.11
|
|
76
76
|
[1.0.10]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.10
|
|
77
77
|
[1.0.9]: https://github.com/revenium/revenium-middleware-openai-node/releases/tag/v1.0.9
|