@layer-ai/core 2.0.29 → 2.0.30

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.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-completions.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/chat-completions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAcpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AAqSpC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"chat-completions.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/chat-completions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAcpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AAkTpC,eAAe,MAAM,CAAC"}
@@ -32,11 +32,22 @@ router.post('/', authenticate, async (req, res) => {
32
32
  let layerRequest = null;
33
33
  try {
34
34
  const openaiReq = req.body;
35
- const gateId = openaiReq.gateId || req.headers['x-layer-gate-id'];
35
+ // Extract gate ID from multiple possible sources
36
+ let gateId = openaiReq.gateId || req.headers['x-layer-gate-id'];
37
+ // If not found in body or header, try to extract from model field
38
+ if (!gateId && openaiReq.model) {
39
+ const modelStr = openaiReq.model;
40
+ // Try to extract UUID from model field (e.g., "layer/82ab7591-..." or "layer:82ab7591-..." or just "82ab7591-...")
41
+ const uuidPattern = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
42
+ const match = modelStr.match(uuidPattern);
43
+ if (match) {
44
+ gateId = match[0];
45
+ }
46
+ }
36
47
  if (!gateId) {
37
48
  const error = {
38
49
  error: {
39
- message: 'Missing required field: gateId (provide in request body or X-Layer-Gate-Id header)',
50
+ message: 'Missing required field: gateId (provide in request body, X-Layer-Gate-Id header, or as part of model field)',
40
51
  type: 'invalid_request_error',
41
52
  param: 'gateId',
42
53
  code: 'missing_field',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layer-ai/core",
3
- "version": "2.0.29",
3
+ "version": "2.0.30",
4
4
  "description": "Core API routes and services for Layer AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",