Skip to content
Docs Try Aspire

GitHubModelsExtensions Methods

Class Methods 4 members
Provides extension methods for adding GitHub Models resources to the application model.
AddGitHubModel(IDistributedApplicationBuilder, string, string, IResourceBuilder<ParameterResource>) Section titled AddGitHubModel(IDistributedApplicationBuilder, string, string, IResourceBuilder<ParameterResource>) extension IResourceBuilder<GitHubModelResource>
Adds a GitHub Model resource to the application model.
public static class GitHubModelsExtensions
{
public static IResourceBuilder<GitHubModelResource> AddGitHubModel(
this IDistributedApplicationBuilder builder,
string name,
string model,
IResourceBuilder<ParameterResource>? organization = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
model string The model name to use with GitHub Models.
organization IResourceBuilder<ParameterResource> optional The organization login associated with the organization to which the request is to be attributed.
IResourceBuilder<GitHubModelResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddGitHubModel(IDistributedApplicationBuilder, string, GitHubModel, IResourceBuilder<ParameterResource>) Section titled AddGitHubModel(IDistributedApplicationBuilder, string, GitHubModel, IResourceBuilder<ParameterResource>) extension IResourceBuilder<GitHubModelResource>
Adds a GitHub Model resource to the application model using a GitHubModel.
public static class GitHubModelsExtensions
{
public static IResourceBuilder<GitHubModelResource> AddGitHubModel(
this IDistributedApplicationBuilder builder,
string name,
GitHubModel model,
IResourceBuilder<ParameterResource>? organization = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
model GitHubModel The model descriptor, using the GitHubModel class like so:
builder.AddGitHubModel(
name: "chat",
model: GitHubModel.Microsoft.Phi3MediumInstruct)
organization IResourceBuilder<ParameterResource> optional The organization login associated with the organization to which the request is to be attributed.
IResourceBuilder<GitHubModelResource> A reference to the ApplicationModel.IResourceBuilder`1.
Create a GitHub Model resource for the Microsoft Phi-3 Medium Instruct model:
var builder = DistributedApplication.CreateBuilder(args);
var githubModel = builder.AddGitHubModel(
"chat",
GitHubModel.Microsoft.Phi3MediumInstruct);
WithApiKey(IResourceBuilder<GitHubModelResource>, IResourceBuilder<ParameterResource>) Section titled WithApiKey(IResourceBuilder<GitHubModelResource>, IResourceBuilder<ParameterResource>) extension IResourceBuilder<GitHubModelResource>
Configures the API key for the GitHub Model resource from a parameter.
public static class GitHubModelsExtensions
{
public static IResourceBuilder<GitHubModelResource> WithApiKey(
this IResourceBuilder<GitHubModelResource> builder,
IResourceBuilder<ParameterResource> apiKey)
{
// ...
}
}
builder IResourceBuilder<GitHubModelResource> The resource builder.
apiKey IResourceBuilder<ParameterResource> The API key parameter.
IResourceBuilder<GitHubModelResource> The resource builder.
ArgumentException Thrown when the provided parameter is not marked as secret.
WithHealthCheck(IResourceBuilder<GitHubModelResource>) Section titled WithHealthCheck(IResourceBuilder<GitHubModelResource>) extension IResourceBuilder<GitHubModelResource>
Adds a health check to the GitHub Model resource.
public static class GitHubModelsExtensions
{
public static IResourceBuilder<GitHubModelResource> WithHealthCheck(
this IResourceBuilder<GitHubModelResource> builder)
{
// ...
}
}
builder IResourceBuilder<GitHubModelResource> The resource builder.
IResourceBuilder<GitHubModelResource> The resource builder.

This method adds a health check that verifies the GitHub Models endpoint is accessible, the API key is valid, and the specified model is available. The health check will:

Because health checks are included in the rate limit of the GitHub Models API, it is recommended to use this health check sparingly, such as when you are having issues understanding the reason the model is not working as expected. Furthermore, the health check will run a single time per application instance.