Skip to content

Connections

Connections sidebar showing configured providers

Connections define how the Prompty extension reaches an LLM provider. Each connection stores an endpoint, authentication credentials, and provider-specific settings so you can run .prompty files directly from VS Code without managing environment variables by hand.

The extension ships with built-in support for three providers:

ProviderAuth MethodModel Discovery
OpenAIAPI key✅ Lists available models via the OpenAI API
AnthropicAPI key✅ Lists available models via the Anthropic API
Microsoft FoundryAzure AD / API key✅ Lists deployed models from your Foundry project

You can configure multiple connections per provider and mark one as the default — the extension uses that default whenever a .prompty file doesn’t specify a connection explicitly.


Connection profiles are saved to a .prompty/connections.json file in your workspace root. Secrets (API keys, tokens) are stored separately in VS Code’s SecretStorage — they never appear in the JSON file on disk.

A typical connections.json looks like this:

.prompty/connections.json
{
"openai-dev": {
"provider": "openai",
"endpoint": "https://api.openai.com/v1",
"isDefault": true
},
"azure-prod": {
"provider": "foundry",
"endpoint": "https://my-resource.services.ai.azure.com/api/projects/my-project",
"isDefault": false
}
}

Each key is the connection name you chose during setup. The isDefault flag controls which connection is used when multiple connections exist for the same provider.


Open the Connections panel in the sidebar and click the + button (or run the Prompty: Add Connection command from the Command Palette). The extension walks you through a four-step wizard:

  1. Pick a provider — OpenAI, Anthropic, or Microsoft Foundry
  2. Enter a name — a short label for this connection (e.g. openai-dev)
  3. Provide credentials — endpoint URL and API key (or Azure AD for Foundry)
  4. Test (optional) — the wizard offers to test the connection before saving

After the wizard completes, the connection appears in the sidebar and is ready to use.

StepFieldRequiredDefault
1Connection name
2API key
3Endpointhttps://api.openai.com/v1
4Modelgpt-4o
StepFieldRequiredDefault
1Connection name
2API key
3Endpointhttps://api.anthropic.com
4Modelclaude-sonnet-4-6

Microsoft Foundry connections use Azure AD authentication instead of API keys. The extension obtains a bearer token via DefaultAzureCredential, so you must be logged in to Azure (e.g., via the Azure CLI or the VS Code Azure Account extension).

StepFieldRequiredDefault
1Connection name
2Project endpoint
3Foundry connection name
4Tenant ID

Right-click any connection in the sidebar and select Test Connection, or click the plug icon that appears inline. You can also run Prompty: Test Connection from the Command Palette. The extension runs a lightweight check for each provider:

ProviderWhat the test doesOn success
OpenAICalls models.list()Reports latency
AnthropicSends a minimal messages requestReports HTTP 200
FoundryAuthenticates with Azure AD, calls deployments endpointReports deployment count and credential source

After the test, the connection’s status icon updates in the sidebar:

  • Connected — all checks passed
  • Failed — one or more checks failed (hover for details)

To update an existing connection, right-click it in the Connections panel and select Edit Connection (or run Prompty: Edit Connection from the Command Palette).

The wizard reopens with your current settings pre-filled. You can change any field — name, endpoint, or credentials. When you save:

  • The profile in .prompty/connections.json is updated
  • If you changed the secret (API key), the old SecretStorage entry is replaced
  • The isDefault flag is preserved unless you explicitly change it

Right-click a connection in the sidebar and select Delete Connection, or run Prompty: Delete Connection from the Command Palette.

Deleting a connection removes both:

  1. The profile entry from .prompty/connections.json
  2. The associated secret from VS Code’s SecretStorage

When you have multiple connections for the same provider, you can mark one as the default. Right-click a connection and select Set as Default, or click the star icon. The default connection is set per provider type — you can have one default OpenAI connection and one default Foundry connection simultaneously.

The extension resolves which connection to use in this order:

PrioritySourceExample
1Frontmatter model.connectionExplicit endpoint + key in the .prompty file
2Provider defaultThe default connection for the provider named in model.provider
3Any defaultFalls back to any connection marked as default

The status bar at the bottom of the VS Code window shows your current default connection — click it to quickly switch defaults.


Expand any connection in the Connections panel to reveal a Models section. The extension queries the provider’s API and lists all models available under that connection.

  • OpenAI — lists all models your API key has access to
  • Anthropic — lists available Claude model variants
  • Microsoft Foundry — lists models deployed in your Foundry project

Model IDs from this list are what you use in the model.id field of your .prompty frontmatter:

model:
id: gpt-4o # ← model ID from the discovery list
provider: openai

Click the refresh icon next to the Models heading to re-fetch the model list (for example, after deploying a new model to your Foundry project). The language server also uses discovered models to offer completions when you type model.id in a .prompty file.


Click the refresh button in the Connections panel toolbar to reload all connections from disk and re-authenticate with each provider.

This is useful when:

  • You edited .prompty/connections.json outside of VS Code
  • An API key or Azure AD token has expired and needs re-acquisition
  • You switched Azure accounts and want to pick up the new credentials
  • Another workspace tool modified the connections file

The refresh re-reads connections.json, re-validates secrets in SecretStorage, and updates the sidebar tree. Any connection whose credentials are no longer valid will show a failed status icon.