@layer-ai/sdk 2.5.6 → 2.5.7

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.
@@ -9,4 +9,5 @@ export * from './smart-routing.js';
9
9
  export * from './config.js';
10
10
  export * from './provider-keys.js';
11
11
  export * from './history.js';
12
+ export * from './openai-format.js';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
@@ -10,3 +10,4 @@ export * from './smart-routing.js';
10
10
  export * from './config.js';
11
11
  export * from './provider-keys.js';
12
12
  export * from './history.js';
13
+ export * from './openai-format.js';
@@ -0,0 +1,147 @@
1
+ /**
2
+ * OpenAI-compatible types for /v1/chat/completions endpoint
3
+ * These match the official OpenAI API format to enable drop-in replacement
4
+ */
5
+ export interface OpenAIMessage {
6
+ role: 'system' | 'user' | 'assistant' | 'tool' | 'function';
7
+ content?: string | OpenAIMessageContent[];
8
+ name?: string;
9
+ tool_calls?: OpenAIToolCall[];
10
+ tool_call_id?: string;
11
+ function_call?: {
12
+ name: string;
13
+ arguments: string;
14
+ };
15
+ }
16
+ export type OpenAIMessageContent = {
17
+ type: 'text';
18
+ text: string;
19
+ } | {
20
+ type: 'image_url';
21
+ image_url: {
22
+ url: string;
23
+ detail?: 'auto' | 'low' | 'high';
24
+ };
25
+ };
26
+ export interface OpenAITool {
27
+ type: 'function';
28
+ function: {
29
+ name: string;
30
+ description?: string;
31
+ parameters?: Record<string, unknown>;
32
+ };
33
+ }
34
+ export interface OpenAIToolCall {
35
+ id: string;
36
+ type: 'function';
37
+ function: {
38
+ name: string;
39
+ arguments: string;
40
+ };
41
+ }
42
+ export type OpenAIToolChoice = 'auto' | 'required' | 'none' | {
43
+ type: 'function';
44
+ function: {
45
+ name: string;
46
+ };
47
+ };
48
+ export interface OpenAIResponseFormat {
49
+ type: 'text' | 'json_object' | 'json_schema';
50
+ json_schema?: {
51
+ name: string;
52
+ description?: string;
53
+ schema: Record<string, unknown>;
54
+ strict?: boolean;
55
+ };
56
+ }
57
+ export interface OpenAIChatCompletionRequest {
58
+ model: string;
59
+ messages: OpenAIMessage[];
60
+ temperature?: number;
61
+ top_p?: number;
62
+ n?: number;
63
+ stream?: boolean;
64
+ stop?: string | string[];
65
+ max_tokens?: number;
66
+ max_completion_tokens?: number;
67
+ presence_penalty?: number;
68
+ frequency_penalty?: number;
69
+ logit_bias?: Record<string, number>;
70
+ user?: string;
71
+ tools?: OpenAITool[];
72
+ tool_choice?: OpenAIToolChoice;
73
+ response_format?: OpenAIResponseFormat;
74
+ seed?: number;
75
+ logprobs?: boolean;
76
+ top_logprobs?: number;
77
+ parallel_tool_calls?: boolean;
78
+ gateId?: string;
79
+ }
80
+ export interface OpenAIUsage {
81
+ prompt_tokens: number;
82
+ completion_tokens: number;
83
+ total_tokens: number;
84
+ }
85
+ export interface OpenAIChatCompletionChoice {
86
+ index: number;
87
+ message: OpenAIMessage;
88
+ finish_reason: 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call' | null;
89
+ logprobs?: null | {
90
+ content: Array<{
91
+ token: string;
92
+ logprob: number;
93
+ bytes: number[] | null;
94
+ top_logprobs: Array<{
95
+ token: string;
96
+ logprob: number;
97
+ bytes: number[] | null;
98
+ }>;
99
+ }> | null;
100
+ };
101
+ }
102
+ export interface OpenAIChatCompletionResponse {
103
+ id: string;
104
+ object: 'chat.completion';
105
+ created: number;
106
+ model: string;
107
+ choices: OpenAIChatCompletionChoice[];
108
+ usage: OpenAIUsage;
109
+ system_fingerprint?: string;
110
+ }
111
+ export interface OpenAIChatCompletionChunkDelta {
112
+ role?: 'system' | 'user' | 'assistant' | 'tool';
113
+ content?: string;
114
+ tool_calls?: Array<{
115
+ index: number;
116
+ id?: string;
117
+ type?: 'function';
118
+ function?: {
119
+ name?: string;
120
+ arguments?: string;
121
+ };
122
+ }>;
123
+ }
124
+ export interface OpenAIChatCompletionChunkChoice {
125
+ index: number;
126
+ delta: OpenAIChatCompletionChunkDelta;
127
+ finish_reason: 'stop' | 'length' | 'tool_calls' | 'content_filter' | null;
128
+ logprobs?: null;
129
+ }
130
+ export interface OpenAIChatCompletionChunk {
131
+ id: string;
132
+ object: 'chat.completion.chunk';
133
+ created: number;
134
+ model: string;
135
+ choices: OpenAIChatCompletionChunkChoice[];
136
+ usage?: OpenAIUsage;
137
+ system_fingerprint?: string;
138
+ }
139
+ export interface OpenAIError {
140
+ error: {
141
+ message: string;
142
+ type: string;
143
+ param?: string | null;
144
+ code?: string | null;
145
+ };
146
+ }
147
+ //# sourceMappingURL=openai-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-format.d.ts","sourceRoot":"","sources":["../../src/types/openai-format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,GA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ACd,KAAK,EAAE,8BAA8B,CAAC;IACtC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC1E,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,uBAAuB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,+BAA+B,EAAE,CAAC;IAC3C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAID,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;CACH"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * OpenAI-compatible types for /v1/chat/completions endpoint
3
+ * These match the official OpenAI API format to enable drop-in replacement
4
+ */
5
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layer-ai/sdk",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "Configure multiple AI models at runtime without code changes or deployments",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",