Skip to content

Connection Registry

The connection registry lets application code register preconfigured clients or connection settings by name. A .prompty file can then use connection.kind: reference without embedding secrets in the file.

from openai import AzureOpenAI
import prompty
client = AzureOpenAI(
azure_endpoint=os.environ["AZURE_ENDPOINT"],
api_key=os.environ["AZURE_API_KEY"],
)
prompty.register_connection("my-foundry", client=client)
client = prompty.get_connection("my-foundry")
prompty.clear_connections()
model:
id: gpt-4o
provider: foundry
connection:
kind: reference
name: my-foundry

Use references for environment-specific values, authenticated SDK clients, and test fixtures. Use explicit key, remote, anonymous, foundry, or oauth connections when the configuration should live directly in the prompt.

For connection data shapes, see Connection.