Class FoundryBackend.Builder
-
- All Implemented Interfaces:
public final class FoundryBackend.BuilderA builder for a FoundryBackend used to connect an Anthropic client to an Anthropic model on the Microsoft Foundry backend service.
The configuration (using an API key) can be resolved from the environment and set on the builder by calling fromEnv before calling build to create the FoundryBackend. Alternatively, set the API key or the bearer token supplier and the resource or base URL explicitly via apiKey or bearerTokenSupplier and resource or baseUrl before calling build.
-
-
Method Summary
Modifier and Type Method Description final FoundryBackend.BuilderfromEnv()Sets the API key and the resource or base URL from values in environment variables. final FoundryBackend.BuilderapiKey(String apiKey)final FoundryBackend.BuilderbearerTokenSupplier(Supplier<String> bearerTokenSupplier)Sets a bearer token supplier that will be responsible for supplying authorization tokens when authorizing requests. final FoundryBackend.Builderresource(String resource)final FoundryBackend.BuilderbaseUrl(String baseUrl)final FoundryBackendbuild()-
-
Method Detail
-
fromEnv
final FoundryBackend.Builder fromEnv()
Sets the API key and the resource or base URL from values in environment variables.
Use the
ANTHROPIC_FOUNDRY_API_KEYenvironment variable to set the API key.Use the
ANTHROPIC_FOUNDRY_RESOURCEenvironment variable to set the resource name. This must be set if the base URL is not set (a base URL includes a resource name). If the resource name is set, the default base URL will be used and will include this resource name.Use the
ANTHROPIC_FOUNDRY_BASE_URLenvironment variable to set an alternative base URL instead of using the default base URL. The base URL includes the resource name, so this must be set if the resource name is not set.If using Microsoft Entra ID or other credentials that require a bearer token, set the bearerTokenSupplier and one of resource and baseUrl separately, as fromEnv requires that an API key environment variable be set.
-
apiKey
final FoundryBackend.Builder apiKey(String apiKey)
-
bearerTokenSupplier
final FoundryBackend.Builder bearerTokenSupplier(Supplier<String> bearerTokenSupplier)
Sets a bearer token supplier that will be responsible for supplying authorization tokens when authorizing requests.
Supplier.get()will be called for each request, allowing the supplier to implement its own token caching/refreshing logic.
-
resource
final FoundryBackend.Builder resource(String resource)
-
baseUrl
final FoundryBackend.Builder baseUrl(String baseUrl)
-
build
final FoundryBackend build()
-
-
-
-