Commit Graph

1 Commits

Author SHA1 Message Date
DragonFSKY a9d65b36b5
Chroma: support custom HTTP client builder and headers (#5040)
## Issue
Addresses #4594

## Change
- Added `httpClientBuilder(...)` to `ChromaEmbeddingStore.Builder`,
allowing users to provide an explicit HTTP client builder instead of
relying on ServiceLoader discovery.
- Added static and supplier-based `customHeaders(...)` support for
Chroma API v1 and v2 requests.
- Preserved the default HTTP client discovery path when no custom
builder or headers are configured.

Chroma token authentication is header-based, including `Authorization:
Bearer <token>` and `X-Chroma-Token`, so custom headers cover secured
Chroma deployments without adding Chroma-specific auth options for each
header style.

Reference:
https://github.com/chroma-core/docs/blob/main/docs/usage-guide.md#authentication

Tested with:
- `./mvnw -pl langchain4j-chroma -am
-Dtest=ChromaEmbeddingStoreHttpClientBuilderTest -DskipITs
-Dsurefire.failIfNoSpecifiedTests=false test`

## General checklist
- [X] There are no breaking changes (API, behaviour)
- [X] I have added unit and/or integration tests for my change
- [X] The tests cover both positive and negative cases
- [ ] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
\"big\" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)

## Checklist for adding new maven module
Not applicable.

## Checklist for adding new embedding store integration
Not applicable.

## Checklist for changing existing embedding store integration
- [ ] I have manually verified that the `ChromaEmbeddingStore` works
correctly with the data persisted using the latest released version of
LangChain4j
2026-04-29 14:05:44 +02:00