From d30590f386a75a4c44000bff02ab7f31c8c5769d Mon Sep 17 00:00:00 2001 From: Matthias Kuhr Date: Wed, 4 Sep 2024 13:11:54 +0200 Subject: [PATCH] Add Metering Header --- core/src/main/java/com/sap/ai/sdk/core/Core.java | 1 + core/src/test/java/com/sap/ai/sdk/core/CoreTest.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/sap/ai/sdk/core/Core.java b/core/src/main/java/com/sap/ai/sdk/core/Core.java index 896d0c0f..1732b491 100644 --- a/core/src/main/java/com/sap/ai/sdk/core/Core.java +++ b/core/src/main/java/com/sap/ai/sdk/core/Core.java @@ -162,6 +162,7 @@ static HttpDestination getDestination(@Nullable final String serviceKey) { // generated code this is actually necessary, because the generated code assumes this // path to be present on the destination .uri(destination.getUri().resolve("/v2")) + .header("AI-Client-Type", "AI SDK Java") .build(); return destination; } diff --git a/core/src/test/java/com/sap/ai/sdk/core/CoreTest.java b/core/src/test/java/com/sap/ai/sdk/core/CoreTest.java index 5ffc50de..021d05aa 100644 --- a/core/src/test/java/com/sap/ai/sdk/core/CoreTest.java +++ b/core/src/test/java/com/sap/ai/sdk/core/CoreTest.java @@ -44,7 +44,7 @@ void getDestinationWithEnvVarSucceedsLocally() { } } """; - assertThat(getDestination(AICORE_SERVICE_KEY).asHttp().getUri().toString()) - .isEqualTo("https://api.ai.core/v2"); + var result = getDestination(AICORE_SERVICE_KEY).asHttp(); + assertThat(result.getUri()).hasToString("https://api.ai.core/v2"); } }