Skip to content

Commit 3ed2882

Browse files
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
1 parent b8dfc09 commit 3ed2882

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
@@ -132,6 +132,7 @@ public OpenAiApi(String baseUrl, ApiKey apiKey, MultiValueMap<String, String> he
132132
// @formatter:off
133133
Consumer<HttpHeaders> finalHeaders = h -> {
134134
h.setContentType(MediaType.APPLICATION_JSON);
135+
h.set("User-Agent", "spring-ai");
135136
h.addAll(headers);
136137
};
137138
this.restClient = restClientBuilder.clone()

0 commit comments

Comments
 (0)