Class FoundryBackend.Builder

  • All Implemented Interfaces:

    
    public final class FoundryBackend.Builder
    
                        

    A 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.

    • Constructor Detail

    • 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_KEY environment variable to set the API key.

        Use the ANTHROPIC_FOUNDRY_RESOURCE environment 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_URL environment 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.

      • 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.