diff --git a/packages/vertex-sdk/src/client.ts b/packages/vertex-sdk/src/client.ts index 61f67582..06231649 100644 --- a/packages/vertex-sdk/src/client.ts +++ b/packages/vertex-sdk/src/client.ts @@ -114,6 +114,12 @@ export class AnthropicVertex extends Core.APIClient { url: string; timeout: number; } { + if (Core.isObj(options.body)) { + // create a shallow copy of the request body so that code that mutates it later + // doesn't mutate the original user-provided object + options.body = { ...options.body }; + } + if (Core.isObj(options.body)) { if (!options.body['anthropic_version']) { options.body['anthropic_version'] = DEFAULT_VERSION;