<jupyter_start><jupyter_text>Connection ManagementPrompt flow provides various prebuilt connections, including Azure Open AI, Open AI, Azure Content Safety, etc. Prebuilt connections enable seamless integration with these resources within the built-in tools. Additionally, users have the flexibility to create custom connection types using key-value pairs, empowering them to tailor the connections to their specific requirements, particularly in Python tools.Reach more details about connection types [here](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/concept-connections?view=azureml-api-2). Create different type of connectionsWe will use Azure Open AI connection and custom connection as example to show how to create connection with promptflow sdk.  Install dependent packages<jupyter_code>%pip install -r ../requirements.txt<jupyter_output><empty_output><jupyter_text>Initialize a pf client<jupyter_code>from promptflow import PFClient

# client can help manage your runs and connections.
client = PFClient()<jupyter_output><empty_output><jupyter_text>Create an Azure Open AI connectionPrepare your Azure Open AI resource follow this [instruction](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal) and get your `api_key` if you don't have one.<jupyter_code>from promptflow.entities import AzureOpenAIConnection

# Initialize an AzureOpenAIConnection object
connection = AzureOpenAIConnection(
    name="my_azure_open_ai_connection",
    api_key="<your-api-key>",
    api_base="<your-endpoint>",
)
# Create the connection, note that api_key will be scrubbed in the returned result
result = client.connections.create_or_update(connection)
print(result)<jupyter_output><empty_output><jupyter_text>Create a custom connection<jupyter_code>from promptflow.entities import CustomConnection

# Initialize a custom connection object
connection = CustomConnection(
    name="my_custom_connection",
    # Secrets is a required field for custom connection
    secrets={"my_key": "<your-api-key>"},
    configs={"endpoint": "<your-endpoint>", "other_config": "other_value"},
)
# Create the connection, note that all secret values will be scrubbed in the returned result
result = client.connections.create_or_update(connection)
print(result)<jupyter_output><empty_output><jupyter_text>List all connections<jupyter_code>connections = client.connections.list()
for connection in connections:
    print(connection)<jupyter_output><empty_output><jupyter_text>Get a connection by name<jupyter_code>connection = client.connections.get(name="my_custom_connection")
print(connection)<jupyter_output><empty_output><jupyter_text>Delete a connection by name  Update a connection Update an Azure Open AI connection<jupyter_code>connection = client.connections.get(name="my_azure_open_ai_connection")
connection.api_base = "new_value"
connection.api_key = (
    "<original-key>"  # secrets are required again when updating connection using sdk
)
result = client.connections.create_or_update(connection)
print(connection)<jupyter_output><empty_output><jupyter_text>Update a custom connection<jupyter_code>connection = client.connections.get(name="my_custom_connection")
connection.configs["other_config"] = "new_value"
connection.secrets[
    "my_key"
] = "new_secret_value"  # ValueError: Connection 'my_custom_connection' secrets ['my_key'] must be filled again when updating it.
result = client.connections.create_or_update(connection)
print(connection)
# client.connections.delete(name="my_custom_connection")<jupyter_output><empty_output>