Class NamedProviderConfig

java.lang.Object
com.github.copilot.rpc.NamedProviderConfig

@CopilotExperimental public class NamedProviderConfig extends Object
A named BYOK (Bring Your Own Key) provider connection in the multi-provider registry.

Unlike ProviderConfig, which routes the entire session through a single provider, named providers are additive: the session keeps its default Copilot routing and exposes these providers' models alongside it. Models are attached via ProviderModelConfig, which references a provider by name. All setter methods return this for method chaining.

Experimental. Multi-provider BYOK configuration is experimental and may change or be removed in future SDK or CLI releases.

Example Usage

var provider = new NamedProviderConfig().setName("my-openai").setType("openai")
		.setBaseUrl("https://api.openai.com/v1").setApiKey("sk-...");
Since:
1.0.0
See Also:
  • Constructor Details

    • NamedProviderConfig

      public NamedProviderConfig()
  • Method Details

    • getName

      public String getName()
      Gets the unique provider name.
      Returns:
      the provider name
    • setName

      public NamedProviderConfig setName(String name)
      Sets the unique provider name.

      Referenced by ProviderModelConfig.setProvider(String) to attach models to this connection.

      Parameters:
      name - the provider name
      Returns:
      this config for method chaining
    • getType

      public String getType()
      Gets the provider type.
      Returns:
      the provider type (e.g., "openai", "azure", "anthropic")
    • setType

      public NamedProviderConfig setType(String type)
      Sets the provider type.

      Supported types include:

      • "openai" - OpenAI API
      • "azure" - Azure OpenAI Service
      • "anthropic" - Anthropic API
      Parameters:
      type - the provider type
      Returns:
      this config for method chaining
    • getWireApi

      public String getWireApi()
      Gets the wire API format.
      Returns:
      the wire API format
    • setWireApi

      public NamedProviderConfig setWireApi(String wireApi)
      Sets the wire API format (openai/azure only).

      Either "completions" or "responses". Defaults to "completions".

      Parameters:
      wireApi - the wire API format
      Returns:
      this config for method chaining
    • getBaseUrl

      public String getBaseUrl()
      Gets the base URL for the API.
      Returns:
      the API base URL
    • setBaseUrl

      public NamedProviderConfig setBaseUrl(String baseUrl)
      Sets the base URL for the API.

      For OpenAI, this is typically "https://api.openai.com/v1".

      Parameters:
      baseUrl - the API base URL
      Returns:
      this config for method chaining
    • getApiKey

      public String getApiKey()
      Gets the API key.
      Returns:
      the API key
    • setApiKey

      public NamedProviderConfig setApiKey(String apiKey)
      Sets the API key for authentication. Optional for local providers like Ollama.
      Parameters:
      apiKey - the API key
      Returns:
      this config for method chaining
    • getBearerToken

      public String getBearerToken()
      Gets the bearer token.
      Returns:
      the bearer token
    • setBearerToken

      public NamedProviderConfig setBearerToken(String bearerToken)
      Sets a bearer token for authentication.

      Sets the Authorization header directly and takes precedence over setApiKey(String) when both are set.

      Note: The bearer token is a static token string. The SDK does not refresh this token automatically.

      Parameters:
      bearerToken - the bearer token
      Returns:
      this config for method chaining
    • getBearerTokenProvider

      public BearerTokenProvider getBearerTokenProvider()
      Gets the bearer-token provider callback.
      Returns:
      the bearer-token provider callback, or null if not set
    • setBearerTokenProvider

      public NamedProviderConfig setBearerTokenProvider(BearerTokenProvider bearerTokenProvider)
      Sets a callback that supplies bearer tokens for outbound provider requests.

      Experimental. The callback stays SDK-side and is not serialized. Instead, the runtime receives a hasBearerTokenProvider flag and calls back over the session-scoped providerToken.getToken RPC before each model request. Return the raw token without a Bearer prefix.

      Parameters:
      bearerTokenProvider - the bearer-token provider callback
      Returns:
      this config for method chaining
    • getAzure

      public AzureOptions getAzure()
      Gets the Azure-specific options.
      Returns:
      the Azure options
    • setAzure

      public NamedProviderConfig setAzure(AzureOptions azure)
      Sets Azure-specific options for Azure OpenAI Service.
      Parameters:
      azure - the Azure options
      Returns:
      this config for method chaining
      See Also:
    • getHeaders

      public Map<String,String> getHeaders()
      Gets the custom HTTP headers for outbound provider requests.
      Returns:
      the headers map, or null if not set
    • setHeaders

      public NamedProviderConfig setHeaders(Map<String,String> headers)
      Sets custom HTTP headers to include in outbound provider requests.
      Parameters:
      headers - the headers map
      Returns:
      this config for method chaining