Skip to content

Commit 62fc70f

Browse files
SandraAhlgrimmsobychacko
authored andcommitted
Add User-Agent header with 'spring-ai' value to OpenAI API client
- Adds 'User-Agent: spring-ai' header to all OpenAI API requests - Maintains consistency with Azure OpenAI implementation - Header is set in the RestClient default headers configuration - Helps OpenAI identify requests coming from Spring AI for analytics and support Signed-off-by: Sandra Ahlgrimm <sandra.kriemann@gmail.com>
1 parent 77473d6 commit 62fc70f

File tree

1 file changed

+1
-0
lines changed
  • models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api

1 file changed

+1
-0
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiApi.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public OpenAiApi(String baseUrl, ApiKey apiKey, MultiValueMap<String, String> he
140140
// @formatter:off
141141
Consumer<HttpHeaders> finalHeaders = h -> {
142142
h.setContentType(MediaType.APPLICATION_JSON);
143+
h.set("User-Agent", "spring-ai");
143144
h.addAll(headers);
144145
};
145146
this.restClient = restClientBuilder.clone()

0 commit comments

Comments
 (0)