@kylindc/ccxray 1.2.1 → 1.2.2
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/package.json +1 -1
- package/server/forward.js +10 -1
package/package.json
CHANGED
package/server/forward.js
CHANGED
|
@@ -36,7 +36,16 @@ function forwardBedrockRequest(ctx) {
|
|
|
36
36
|
const { id, ts, startTime, parsedBody, rawBody, clientReq, clientRes, reqSessionId } = ctx;
|
|
37
37
|
|
|
38
38
|
const statsStripped = stripInjectedStats(parsedBody);
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
// Translate the Anthropic API body to Bedrock native format:
|
|
41
|
+
// - add anthropic_version (Bedrock requires it in the body; Claude Code sends it as a header)
|
|
42
|
+
// - strip `model` (encoded in the URL) and `stream` (indicated by the endpoint path)
|
|
43
|
+
const baseBody = parsedBody || JSON.parse(rawBody.toString());
|
|
44
|
+
const { model: _model, stream: _stream, ...bedrockFields } = baseBody;
|
|
45
|
+
const bodyToSend = Buffer.from(JSON.stringify({
|
|
46
|
+
anthropic_version: 'bedrock-2023-05-31',
|
|
47
|
+
...bedrockFields,
|
|
48
|
+
}));
|
|
40
49
|
|
|
41
50
|
// Resolve Bedrock model ID
|
|
42
51
|
let bedrockModelId;
|