Skip to content
DocsTry Aspire
DocsTry

Set up GitHub Models in the AppHost

GitHub logo

This article is the reference for the Aspire GitHub Models hosting integration. It enumerates the AppHost APIs — with examples for both AppHost.cs and apphost.mts — that you use to model GitHub Model resources in your AppHost project.

If you’re new to the GitHub Models integration, start with the Get started with GitHub Models integrations guide. For how consuming apps read the connection information this page exposes, see Connect to GitHub Models.

To start building an Aspire app that uses GitHub Models, install the 📦 Aspire.Hosting.GitHub.Models NuGet package:

Terminal
aspire add github-models

Learn more about aspire add in the command reference.

This updates your aspire.config.json with the GitHub Models hosting integration package:

aspire.config.json
{
"packages": {
"Aspire.Hosting.GitHub.Models": "13.5.3"
}
}

Once you’ve installed the hosting integration in your AppHost project, you can add a GitHub Model resource:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
,
type GitHubModelName = "AI21Jamba15Large" | "CohereCommandA" | "CohereCommandR082024" | "CohereCommandRPlus082024" | "DeepSeekR1" | "DeepSeekR10528" | "DeepSeekV30324" | "Llama4Maverick17B128EInstructFP8" | "Llama4Scout17B16EInstruct" | "Llama3211BVisionInstruct" | "Llama3290BVisionInstruct" | "Llama3370BInstruct" | "MetaLlama31405BInstruct" | "MetaLlama318BInstruct" | "MaiDSR1" | "Phi4" | "Phi4MiniInstruct" | "Phi4MiniReasoning" | "Phi4MultimodalInstruct" | "Phi4Reasoning" | "Codestral2501" | "Ministral3B" | "MistralMedium32505" | "MistralSmall31" | ... 18 more ... | "Grok3Mini"
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const chat: GitHubModelResource
chat
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addGitHubModel(name: string, model: GitHubModelName, options?: {
organization?: string | ParameterResource;
}): GitHubModelResource (+1 overload)

Adds a GitHub Model resource to the distributed application model.

addGitHubModel
("chat",
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
.
type OpenAIGpt4oMini: "OpenAIGpt4oMini"
OpenAIGpt4oMini
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource

Adds a node application to the application model. Node should be available on the PATH.

addNodeApp
("api", "./api", "index.js")
.
ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): NodeAppResource (+1 overload)

Adds a reference to another resource

withReference
(
const chat: GitHubModelResource
chat
);
// After adding all resources, run the app...
  1. Calling AddGitHubModel (or addGitHubModel) creates a GitHubModelResource. It registers a secret parameter for the API key that defaults to the GITHUB_TOKEN environment variable.

  2. The model identifier selects which GitHub-hosted model to target. In C#, use the strongly-typed GitHubModel constants grouped by publisher; in TypeScript, use the GitHubModelName enum.

  3. The AppHost reference call configures a connection in the consuming project named after the resource (for example, chat in the preceding example).

If you prefer to specify the model by its raw string identifier rather than a constant, use AddGitHubModel (C#) with the string overload or addGitHubModelById (TypeScript):

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const chat: GitHubModelResource
chat
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addGitHubModelById(name: string, modelId: string, options?: {
organization?: string | ParameterResource;
}): GitHubModelResource (+1 overload)

Adds a GitHub Model resource to the application model using a model identifier string.

addGitHubModelById
("chat", "openai/gpt-4o-mini");
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource

Adds a node application to the application model. Node should be available on the PATH.

addNodeApp
("api", "./api", "index.js")
.
ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): NodeAppResource (+1 overload)

Adds a reference to another resource

withReference
(
const chat: GitHubModelResource
chat
);
// After adding all resources, run the app...

Calling AddGitHubModel("chat", ...) (or addGitHubModel("chat", ...)) automatically creates a secret parameter named chat-gh-apikey. Aspire resolves its value in this order:

  1. The Parameters:chat-gh-apikey configuration key (user secrets, appsettings.*, or environment variables).
  2. The GITHUB_TOKEN environment variable.

If neither source provides a value, startup throws an exception. In Codespaces and GitHub Actions, GITHUB_TOKEN is populated automatically. For local development, provide a fine-grained personal access token with models: read scope via user secrets:

Terminal
aspire secret set Parameters:chat-gh-apikey github_pat_YOUR_TOKEN_HERE

Replace the default parameter by creating your own secret parameter and passing it to WithApiKey (or withApiKey):

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
,
type GitHubModelName = "AI21Jamba15Large" | "CohereCommandA" | "CohereCommandR082024" | "CohereCommandRPlus082024" | "DeepSeekR1" | "DeepSeekR10528" | "DeepSeekV30324" | "Llama4Maverick17B128EInstructFP8" | "Llama4Scout17B16EInstruct" | "Llama3211BVisionInstruct" | "Llama3290BVisionInstruct" | "Llama3370BInstruct" | "MetaLlama31405BInstruct" | "MetaLlama318BInstruct" | "MaiDSR1" | "Phi4" | "Phi4MiniInstruct" | "Phi4MiniReasoning" | "Phi4MultimodalInstruct" | "Phi4Reasoning" | "Codestral2501" | "Ministral3B" | "MistralMedium32505" | "MistralSmall31" | ... 18 more ... | "Grok3Mini"
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const apiKey: ParameterResource
apiKey
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("my-gh-token", {
secret?: boolean | undefined
secret
: true });
const
const chat: GitHubModelResource
chat
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addGitHubModel(name: string, model: GitHubModelName, options?: {
organization?: string | ParameterResource;
}): GitHubModelResource (+1 overload)

Adds a GitHub Model resource to the distributed application model.

addGitHubModel
("chat",
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
.
type OpenAIGpt4oMini: "OpenAIGpt4oMini"
OpenAIGpt4oMini
);
await
const chat: GitHubModelResource
chat
.
GitHubModelResource.withApiKey(apiKey: string | ParameterResource): GitHubModelResource

Configures the API key for the GitHub Model resource from a parameter.

withApiKey
(
const apiKey: ParameterResource
apiKey
);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource

Adds a node application to the application model. Node should be available on the PATH.

addNodeApp
("api", "./api", "index.js")
.
ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): NodeAppResource (+1 overload)

Adds a reference to another resource

withReference
(
const chat: GitHubModelResource
chat
);
// After adding all resources, run the app...

For organization-attributed requests, pass an organization parameter:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
,
type GitHubModelName = "AI21Jamba15Large" | "CohereCommandA" | "CohereCommandR082024" | "CohereCommandRPlus082024" | "DeepSeekR1" | "DeepSeekR10528" | "DeepSeekV30324" | "Llama4Maverick17B128EInstructFP8" | "Llama4Scout17B16EInstruct" | "Llama3211BVisionInstruct" | "Llama3290BVisionInstruct" | "Llama3370BInstruct" | "MetaLlama31405BInstruct" | "MetaLlama318BInstruct" | "MaiDSR1" | "Phi4" | "Phi4MiniInstruct" | "Phi4MiniReasoning" | "Phi4MultimodalInstruct" | "Phi4Reasoning" | "Codestral2501" | "Ministral3B" | "MistralMedium32505" | "MistralSmall31" | ... 18 more ... | "Grok3Mini"
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const organization: ParameterResource
organization
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
("github-org");
const
const chat: GitHubModelResource
chat
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addGitHubModel(name: string, model: GitHubModelName, options?: {
organization?: string | ParameterResource;
}): GitHubModelResource (+1 overload)

Adds a GitHub Model resource to the distributed application model.

addGitHubModel
("chat",
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
.
type OpenAIGpt4oMini: "OpenAIGpt4oMini"
OpenAIGpt4oMini
, {
organization?: string | ParameterResource | undefined
organization
,
});
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource

Adds a node application to the application model. Node should be available on the PATH.

addNodeApp
("api", "./api", "index.js")
.
ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): NodeAppResource (+1 overload)

Adds a reference to another resource

withReference
(
const chat: GitHubModelResource
chat
);
// After adding all resources, run the app...

When an organization is specified, the endpoint changes to https://models.github.ai/orgs/{organization}/inference and the token must be attributed to that organization in GitHub.

Add an optional health check to verify endpoint reachability and API key validity:

apphost.mts
import {
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
,
type GitHubModelName = "AI21Jamba15Large" | "CohereCommandA" | "CohereCommandR082024" | "CohereCommandRPlus082024" | "DeepSeekR1" | "DeepSeekR10528" | "DeepSeekV30324" | "Llama4Maverick17B128EInstructFP8" | "Llama4Scout17B16EInstruct" | "Llama3211BVisionInstruct" | "Llama3290BVisionInstruct" | "Llama3370BInstruct" | "MetaLlama31405BInstruct" | "MetaLlama318BInstruct" | "MaiDSR1" | "Phi4" | "Phi4MiniInstruct" | "Phi4MiniReasoning" | "Phi4MultimodalInstruct" | "Phi4Reasoning" | "Codestral2501" | "Ministral3B" | "MistralMedium32505" | "MistralSmall31" | ... 18 more ... | "Grok3Mini"
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
} from './.aspire/modules/aspire.mjs';
const
const builder: IDistributedApplicationBuilder
builder
= await
function createBuilder(): IDistributedApplicationBuilder

Creates a new distributed application builder

createBuilder
();
const
const chat: GitHubModelResource
chat
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addGitHubModel(name: string, model: GitHubModelName, options?: {
organization?: string | ParameterResource;
}): GitHubModelResource (+1 overload)

Adds a GitHub Model resource to the distributed application model.

addGitHubModel
("chat",
const GitHubModelName: {
readonly AI21Jamba15Large: "AI21Jamba15Large";
readonly CohereCommandA: "CohereCommandA";
readonly CohereCommandR082024: "CohereCommandR082024";
readonly CohereCommandRPlus082024: "CohereCommandRPlus082024";
readonly DeepSeekR1: "DeepSeekR1";
readonly DeepSeekR10528: "DeepSeekR10528";
readonly DeepSeekV30324: "DeepSeekV30324";
readonly Llama4Maverick17B128EInstructFP8: "Llama4Maverick17B128EInstructFP8";
readonly Llama4Scout17B16EInstruct: "Llama4Scout17B16EInstruct";
readonly Llama3211BVisionInstruct: "Llama3211BVisionInstruct";
... 32 more ...;
readonly Grok3Mini: "Grok3Mini";
}

Enum Aspire.Hosting.GitHub.GitHubModelName

GitHubModelName
.
type OpenAIGpt4oMini: "OpenAIGpt4oMini"
OpenAIGpt4oMini
);
const chat: GitHubModelResource
chat
.
GitHubModelResource.enableHealthCheck(): GitHubModelResource

Adds a health check to the GitHub Model resource.

enableHealthCheck
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource

Adds a node application to the application model. Node should be available on the PATH.

addNodeApp
("api", "./api", "index.js")
.
ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): NodeAppResource (+1 overload)

Adds a reference to another resource

withReference
(
const chat: GitHubModelResource
chat
);
// After adding all resources, run the app...

GitHub Models supports a broad and growing catalog of models. Use the strongly-typed constants for the most accurate list:

PublisherC# constant (examples)TypeScript enum (examples)
OpenAIGitHubModel.OpenAI.OpenAIGpt4oMiniGitHubModelName.OpenAIGpt4oMini
OpenAIGitHubModel.OpenAI.OpenAIGpt41MiniGitHubModelName.OpenAIGpt41Mini
DeepSeekGitHubModel.DeepSeek.DeepSeekV30324GitHubModelName.DeepSeekV30324
DeepSeekGitHubModel.DeepSeek.DeepSeekR1GitHubModelName.DeepSeekR1
MicrosoftGitHubModel.Microsoft.Phi4MiniInstructGitHubModelName.Phi4MiniInstruct (see note)
MetaGitHubModel.Meta.MetaLlama318BInstructGitHubModelName.MetaLlama318BInstruct

For the full catalogue, visit the GitHub Models Marketplace.

For the full reference of GitHub Models connection properties — and how consuming apps in C#, TypeScript, Python, and Go read them — see Connect to GitHub Models.