genai-lite 0.13.0 → 0.13.1
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.
|
@@ -54,26 +54,15 @@ class AnthropicClientAdapter {
|
|
|
54
54
|
hasStopSequences: !!messageParams.stop_sequences,
|
|
55
55
|
useStructuredOutput,
|
|
56
56
|
});
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
headers: {
|
|
63
|
-
'anthropic-beta': 'structured-outputs-2025-11-13',
|
|
64
|
-
},
|
|
65
|
-
...requestTransportOptions,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
completion =
|
|
70
|
-
Object.keys(requestTransportOptions).length > 0
|
|
71
|
-
? await anthropic.messages.create(messageParams, requestTransportOptions)
|
|
72
|
-
: await anthropic.messages.create(messageParams);
|
|
73
|
-
}
|
|
57
|
+
// Structured and unstructured requests take the same endpoint - structured
|
|
58
|
+
// output is GA, so there is no beta header or beta endpoint involved.
|
|
59
|
+
const completion = Object.keys(requestTransportOptions).length > 0
|
|
60
|
+
? await anthropic.messages.create(messageParams, requestTransportOptions)
|
|
61
|
+
: await anthropic.messages.create(messageParams);
|
|
74
62
|
this.logger.info(`Anthropic API call successful, response ID: ${completion.id}`);
|
|
75
|
-
// Convert to standardized response format
|
|
76
|
-
//
|
|
63
|
+
// Convert to standardized response format. `create` is typed against the
|
|
64
|
+
// streaming/non-streaming param union; we never set `stream`, so this is
|
|
65
|
+
// always a Message.
|
|
77
66
|
return this.createSuccessResponse(completion, request);
|
|
78
67
|
}
|
|
79
68
|
catch (error) {
|
|
@@ -94,17 +83,12 @@ class AnthropicClientAdapter {
|
|
|
94
83
|
let started = false;
|
|
95
84
|
try {
|
|
96
85
|
const { anthropic, messageParams, requestTransportOptions, useStructuredOutput, } = this.prepareMessageRequest(request, apiKey, options);
|
|
97
|
-
this.logger.info(`Making Anthropic streaming API call for model: ${request.modelId}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
...requestTransportOptions,
|
|
104
|
-
}
|
|
105
|
-
: requestTransportOptions;
|
|
106
|
-
const stream = Object.keys(streamOptions).length > 0
|
|
107
|
-
? anthropic.messages.stream(messageParams, streamOptions)
|
|
86
|
+
this.logger.info(`Making Anthropic streaming API call for model: ${request.modelId}`, {
|
|
87
|
+
useStructuredOutput,
|
|
88
|
+
});
|
|
89
|
+
// No beta header for structured output - output_config.format is GA.
|
|
90
|
+
const stream = Object.keys(requestTransportOptions).length > 0
|
|
91
|
+
? anthropic.messages.stream(messageParams, requestTransportOptions)
|
|
108
92
|
: anthropic.messages.stream(messageParams);
|
|
109
93
|
for await (const event of stream) {
|
|
110
94
|
sawEvent = true;
|
|
@@ -254,20 +238,22 @@ class AnthropicClientAdapter {
|
|
|
254
238
|
stop_sequences: request.settings.stopSequences,
|
|
255
239
|
}),
|
|
256
240
|
};
|
|
257
|
-
// Handle structured output configuration for Anthropic
|
|
258
|
-
//
|
|
241
|
+
// Handle structured output configuration for Anthropic.
|
|
242
|
+
// Structured outputs are generally available: the stable request field is
|
|
243
|
+
// output_config.format, with no beta header. The format object carries only
|
|
244
|
+
// `type` and `schema` - the generic StructuredOutputSettings `name` and
|
|
245
|
+
// `strict` fields exist for other providers and are not serialized here.
|
|
259
246
|
if (useStructuredOutput) {
|
|
260
247
|
const so = request.settings.structuredOutput;
|
|
261
248
|
// Anthropic requires additionalProperties: false on all object schemas
|
|
262
249
|
const processedSchema = so.strict !== false
|
|
263
250
|
? this.addAdditionalPropertiesFalse(so.schema)
|
|
264
|
-
: so.schema;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
strict: so.strict !== false,
|
|
251
|
+
: { ...so.schema };
|
|
252
|
+
messageParams.output_config = {
|
|
253
|
+
format: {
|
|
254
|
+
type: "json_schema",
|
|
255
|
+
schema: processedSchema,
|
|
256
|
+
},
|
|
271
257
|
};
|
|
272
258
|
}
|
|
273
259
|
// Handle reasoning/thinking configuration for Claude models
|
package/dist/llm/config.js
CHANGED
|
@@ -873,6 +873,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
873
873
|
outputType: 'summary',
|
|
874
874
|
requiresStreamingAbove: 21333,
|
|
875
875
|
},
|
|
876
|
+
structuredOutput: {
|
|
877
|
+
supported: true,
|
|
878
|
+
strictMode: true,
|
|
879
|
+
},
|
|
876
880
|
},
|
|
877
881
|
{
|
|
878
882
|
id: "claude-sonnet-4-5-20250929",
|
|
@@ -897,6 +901,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
897
901
|
outputType: 'summary',
|
|
898
902
|
requiresStreamingAbove: 21333,
|
|
899
903
|
},
|
|
904
|
+
structuredOutput: {
|
|
905
|
+
supported: true,
|
|
906
|
+
strictMode: true,
|
|
907
|
+
},
|
|
900
908
|
},
|
|
901
909
|
{
|
|
902
910
|
id: "claude-haiku-4-5-20251001",
|
|
@@ -921,8 +929,14 @@ exports.SUPPORTED_MODELS = [
|
|
|
921
929
|
outputType: 'summary',
|
|
922
930
|
requiresStreamingAbove: 21333,
|
|
923
931
|
},
|
|
932
|
+
structuredOutput: {
|
|
933
|
+
supported: true,
|
|
934
|
+
strictMode: true,
|
|
935
|
+
},
|
|
924
936
|
},
|
|
925
937
|
// Anthropic Models - Claude 4 Series
|
|
938
|
+
// Note: Anthropic's structured outputs are generally available for Claude 4.5
|
|
939
|
+
// and later models only, so the entries below declare it unsupported.
|
|
926
940
|
{
|
|
927
941
|
id: "claude-sonnet-4-20250514",
|
|
928
942
|
name: "Claude Sonnet 4",
|
|
@@ -946,6 +960,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
946
960
|
outputType: 'summary',
|
|
947
961
|
requiresStreamingAbove: 21333,
|
|
948
962
|
},
|
|
963
|
+
structuredOutput: {
|
|
964
|
+
supported: false,
|
|
965
|
+
notes: "Anthropic structured outputs require Claude 4.5 or later",
|
|
966
|
+
},
|
|
949
967
|
},
|
|
950
968
|
{
|
|
951
969
|
id: "claude-opus-4-20250514",
|
|
@@ -970,6 +988,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
970
988
|
outputType: 'summary',
|
|
971
989
|
requiresStreamingAbove: 21333,
|
|
972
990
|
},
|
|
991
|
+
structuredOutput: {
|
|
992
|
+
supported: false,
|
|
993
|
+
notes: "Anthropic structured outputs require Claude 4.5 or later",
|
|
994
|
+
},
|
|
973
995
|
},
|
|
974
996
|
{
|
|
975
997
|
id: "claude-3-7-sonnet-20250219",
|
|
@@ -994,6 +1016,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
994
1016
|
outputType: 'full',
|
|
995
1017
|
requiresStreamingAbove: 21333,
|
|
996
1018
|
},
|
|
1019
|
+
structuredOutput: {
|
|
1020
|
+
supported: false,
|
|
1021
|
+
notes: "Anthropic structured outputs require Claude 4.5 or later",
|
|
1022
|
+
},
|
|
997
1023
|
},
|
|
998
1024
|
{
|
|
999
1025
|
id: "claude-3-5-sonnet-20241022",
|
|
@@ -1008,6 +1034,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
1008
1034
|
supportsPromptCache: true,
|
|
1009
1035
|
cacheWritesPrice: 3.75,
|
|
1010
1036
|
cacheReadsPrice: 0.3,
|
|
1037
|
+
structuredOutput: {
|
|
1038
|
+
supported: false,
|
|
1039
|
+
notes: "Anthropic structured outputs require Claude 4.5 or later",
|
|
1040
|
+
},
|
|
1011
1041
|
},
|
|
1012
1042
|
{
|
|
1013
1043
|
id: "claude-3-5-haiku-20241022",
|
|
@@ -1022,6 +1052,10 @@ exports.SUPPORTED_MODELS = [
|
|
|
1022
1052
|
supportsPromptCache: true,
|
|
1023
1053
|
cacheWritesPrice: 1.0,
|
|
1024
1054
|
cacheReadsPrice: 0.08,
|
|
1055
|
+
structuredOutput: {
|
|
1056
|
+
supported: false,
|
|
1057
|
+
notes: "Anthropic structured outputs require Claude 4.5 or later",
|
|
1058
|
+
},
|
|
1025
1059
|
},
|
|
1026
1060
|
// Google Gemini Models - Gemini 3 Series (Preview)
|
|
1027
1061
|
{
|