spring-projects / spring-projects/spring-ai
Add ability to configure custom HTTP headers at ChatClient.Builder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Currently, Spring AI only provides a straightforward way to set custom HTTP headers in certain provider-specific integrations (e.g., spring.ai.azure.openai.custom-headers for Azure OpenAI).
For other providers accessed via the ChatClient API — especially those using OpenAI-compatible endpoints like Google Gemini — there is no native mechanism to set provider-specific HTTP headers during client creation.
Expected Behavior
Enable adding custom HTTP headers directly when building a ChatClient.
For example:
ChatClient client = ChatClient.builder()
.baseUrl("https://generativelanguage.googleapis.com/v1beta/openai/")
.apiKey("...")
.customHeader("X-Server-Throughput-Key", "my-throughput-token")
.customHeader("Another-Header", "value")
.build();
Benefits:
Simplifies integrating with providers that require extra headers (e.g., Gemini throughput provisioning keys, experimental API )
Context
I work for enterprise system. We have reserved provisioning throughput on vertex ai Gemini. But can't use it natively with Spring AI
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ChatClient.Builder and trace how a built client creates HTTP requests for provider-compatible endpoints. Done means custom headers can be supplied during client creation and are included in requests, including multiple headers such as the Gemini throughput key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100