Class NamedProviderConfig
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the API key.getAzure()Gets the Azure-specific options.Gets the base URL for the API.Gets the bearer token.Gets the bearer-token provider callback.Gets the custom HTTP headers for outbound provider requests.Gets the product serving this provider's models.getName()Gets the unique provider name.getType()Gets the provider type.Gets the wire API format.Sets the API key for authentication.setAzure(AzureOptions azure) Sets Azure-specific options for Azure OpenAI Service.setBaseUrl(String baseUrl) Sets the base URL for the API.setBearerToken(String bearerToken) Sets a bearer token for authentication.setBearerTokenProvider(BearerTokenProvider bearerTokenProvider) Sets a callback that supplies bearer tokens for outbound provider requests.setHeaders(Map<String, String> headers) Sets custom HTTP headers to include in outbound provider requests.setModelProvider(String modelProvider) Sets the product serving this provider's models, reported in telemetry asmodel_provider.Sets the unique provider name.Sets the provider type.setWireApi(String wireApi) Sets the wire API format (openai/azure only).
-
Constructor Details
-
NamedProviderConfig
public NamedProviderConfig()
-
-
Method Details
-
getName
-
setName
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
Gets the provider type.- Returns:
- the provider type (e.g., "openai", "azure", "anthropic")
-
setType
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
-
setWireApi
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
-
getModelProvider
Gets the product serving this provider's models.- Returns:
- the model provider, such as "ollama" or "lm_studio"
-
setModelProvider
Sets the product serving this provider's models, reported in telemetry asmodel_provider. Allowed values are "openai", "anthropic", "azure_openai", "ollama", "lm_studio", "foundry_local", and "llama_cpp"; only affects telemetry.- Parameters:
modelProvider- the model provider- Returns:
- this config for method chaining
-
getBaseUrl
-
setBaseUrl
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
-
setApiKey
Sets the API key for authentication. Optional for local providers like Ollama.- Parameters:
apiKey- the API key- Returns:
- this config for method chaining
-
getBearerToken
-
setBearerToken
Sets a bearer token for authentication.Sets the
Authorizationheader directly and takes precedence oversetApiKey(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
Gets the bearer-token provider callback.- Returns:
- the bearer-token provider callback, or
nullif not set
-
setBearerTokenProvider
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
hasBearerTokenProviderflag and calls back over the session-scopedproviderToken.getTokenRPC before each model request. Return the raw token without aBearerprefix.- Parameters:
bearerTokenProvider- the bearer-token provider callback- Returns:
- this config for method chaining
-
getAzure
-
setAzure
Sets Azure-specific options for Azure OpenAI Service.- Parameters:
azure- the Azure options- Returns:
- this config for method chaining
- See Also:
-
getHeaders
-
setHeaders
Sets custom HTTP headers to include in outbound provider requests.- Parameters:
headers- the headers map- Returns:
- this config for method chaining
-