Skip to content

Commit 3182af1

Browse files
authored
Update openapi-spec.md
1 parent 23580d4 commit 3182af1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

articles/ai-services/agents/how-to/tools/openapi-spec.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ work together, generate client code, create tests, apply design standards, and m
3030
## Set up
3131
1. Ensure you've completed the prerequisites and setup steps in the [quickstart](../../quickstart.md).
3232

33+
1. [optional]If your OpenAPI spec requires API key, you can store your API key in a `custom keys` connection and use `connection` authentication
34+
35+
1. Go to the [Azure AI Foundry portal](https://ai.azure.com/) and select the AI Project. Click **connected resources**.
36+
:::image type="content" source="../../media/tools/bing/project-settings-button.png" alt-text="A screenshot of the settings button for an AI project." lightbox="../../media/tools/bing/project-settings-button.png":::
37+
38+
1. Select **+ new connection** in the settings page.
39+
>[!NOTE]
40+
> If you re-generate the API key at a later date, you need to update the connection with the new key.
41+
42+
:::image type="content" source="../../media/tools/bing/project-connections.png" alt-text="A screenshot of the connections screen for the AI project." lightbox="../../media/tools/bing/project-connections.png":::
43+
44+
1. Select **custom keys** in **other resource types**.
45+
![image](https://github.com/user-attachments/assets/2e6e8efe-1a31-4097-a859-58ac5ee17a96)
46+
47+
1. Enter the following information
48+
- `key`: "key"
49+
- value: YOUR_API_KEY
50+
- Connection name: `YOUR_CONNECTION_NAME` (You will use this connection name in the sample code below.)
51+
- Access: you can choose either *this project only* or *shared to all projects*. Just make sure in the sample code below, the project you entered connection string for has access to this connection.
52+
3353
::: zone-end
3454

3555
::: zone pivot="code-example"
@@ -65,6 +85,17 @@ auth = OpenApiAnonymousAuthDetails()
6585
# Initialize agent OpenApi tool using the read in OpenAPI spec
6686
openapi = OpenApiTool(name="get_weather", spec=openapi_spec, description="Retrieve weather information for a location", auth=auth)
6787
```
88+
If you want to use connection, which stores API key, for authentication, replace the line with
89+
```python
90+
auth = OpenApiConnectionAuthDetails(security_scheme=OpenApiConnectionSecurityScheme(connection_id="your_connection_id"))
91+
```
92+
Your connection ID looks like `/subscriptions/{subscription ID}/resourceGroups/{resource group name}/providers/Microsoft.MachineLearningServices/workspaces/{project name}/connections/{connection name}`.
93+
94+
If you want to use managed identity for authentication, replace the line with
95+
```python
96+
auth = OpenApiManagedAuthDetails(security_scheme=OpenApiManagedSecurityScheme(audience="https://your_identity_scope.com"))
97+
```
98+
An example of the audience would be ```https://cognitiveservices.azure.com/```.
6899

69100
## Step 3: Create a thread
70101
```python

0 commit comments

Comments
 (0)