Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this quickstart, you create your first agent in Agents and Tools with Foundry Local. You connect a language model, create an agent with instructions, ask it a question by using the Responses API, and then chat with it in the browser.
Important
Agent creation and management with Foundry Local is available in preview. Preview releases provide early access to features that are in active deployment. Features, approaches, and processes can change or have limited capabilities before general availability (GA). To learn about the legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability, see the Supplemental Terms of Use for Microsoft Azure Previews.
Prerequisites
- A deployment of Agents and Tools with Foundry Local that you can reach at
https://<cluster-domain>. To deploy one, see Quickstart: Deploy Agents and Tools with Foundry Local. - A model served by Foundry Local on the same cluster, or another OpenAI-compatible endpoint. See Set up language model endpoint.
- A Microsoft Entra ID identity with Cognitive Services Contributor to create resources and Cognitive Services OpenAI User to run the agent, assigned at the extension scope. In disconnected deployments, use Contributor. See Assign Azure roles.
- Reader assigned to the extension's managed identity at the extension scope. See Allow the extension to check Azure roles.
- The Azure CLI, and Bash or Python 3.10 or later.
Set up your environment
The following examples use the cluster address and an access token from Microsoft Entra ID. Replace <cluster-domain> with the domain of your deployment, such as arcrag.contoso.com, and <app-registration-client-id> with the application (client) ID of the app registration for Agents and Tools with Foundry Local.
Sign in with the Azure CLI, and save the address and a token in variables:
az login --tenant <your-tenant-id> --output none
BASE="https://<cluster-domain>"
TOKEN=$(az account get-access-token \
--resource "api://<app-registration-client-id>" \
--query accessToken -o tsv)
Connect a language model
Create a model connection named local-model. This example uses a Foundry Local model that accepts an API key. Replace the endpoint, model name, and key with your values.
curl -X PUT "$BASE/connections/local-model" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"type": "ModelConnection",
"kind": "FoundryOnArc",
"endpoint": "https://gpt-oss-20b.foundry-local-operator.svc.cluster.local:5000/v1/",
"model": "gpt-oss-20b",
"authentication": { "type": "ApiKey", "apiKey": "<your-api-key>" },
"maxContextTokens": 131072
}'
The service returns the connection. It never returns your API key:
{
"type": "ModelConnection",
"kind": "FoundryOnArc",
"endpoint": "https://gpt-oss-20b.foundry-local-operator.svc.cluster.local:5000/v1/",
"model": "gpt-oss-20b",
"authentication": { "type": "ApiKey" },
"maxContextTokens": 131072,
"isReasoningModel": false,
"name": "local-model",
"id": "local-model"
}
If your Foundry Local endpoint uses Microsoft Entra ID authentication instead of an API key, set "authentication": { "type": "ManagedIdentity" }. When you use managed identity, a cluster administrator must also approve the model endpoint URL (https://gpt-oss-20b.foundry-local-operator.svc.cluster.local:5000/v1/) in serviceUrls (model-access-arc-rag/mi-destinations). See Create a model connection and Approve endpoints for managed identity.
Create an agent
Create the first version of an agent named quickstart-helper:
curl -X POST "$BASE/agents/quickstart-helper/versions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"description": "A friendly helper for the quickstart.",
"definition": {
"kind": "prompt",
"model": "local-model/gpt-oss-20b",
"instructions": "You are a friendly helper. Answer in two sentences or fewer."
}
}'
The service returns version 1 of the agent:
{
"object": "agent.version",
"id": "quickstart-helper:1",
"name": "quickstart-helper",
"version": "1",
"description": "A friendly helper for the quickstart.",
"created_at": 1792656119,
"definition": {
"kind": "prompt",
"model": "local-model/gpt-oss-20b",
"instructions": "You are a friendly helper. Answer in two sentences or fewer.",
"tools": []
},
"metadata": {},
"status": "active"
}
The agent is enabled right away. Each later change creates a new version with the next number.
Ask the agent a question
Send a question by using the Responses API:
curl -X POST "$BASE/openai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"agent_reference": { "type": "agent_reference", "name": "quickstart-helper" },
"input": "What can you help me with?"
}'
The answer is in the text field of the message item in output. The following output is shortened, and your answer text will be different:
{
"id": "resp_35ce0dd241a44aafb754ec2d6d671955",
"object": "response",
"status": "completed",
"model": "local-model/gpt-oss-20b",
"output": [
{
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "I can answer questions and help you summarize or draft text.",
"annotations": []
}
]
}
],
"warnings": [],
"agent_reference": {
"type": "agent_reference",
"name": "quickstart-helper",
"version": "1"
}
}
Chat with the agent in the browser
- Open the Local chat UI at
https://<cluster-domain>/chatand sign in. - Select quickstart-helper from the list of agents.
- Ask a question.
The agent streams its answer into the chat window. The Local chat UI saves the conversation in the sidebar, so you can come back to it later.
For connected deployments, users who only chat need Reader to list agents and Cognitive Services OpenAI User to run them. In disconnected deployments, use Contributor. EdgeRAGEndUser alone doesn't grant Responses or Conversations access. The EdgeRAGDeveloper app role remains a management fallback and is needed to read full definitions from agent list and get operations.
Clean up resources
To delete the agent and the model connection resources:
curl -X DELETE "$BASE/agents/quickstart-helper" -H "Authorization: Bearer $TOKEN"
curl -X DELETE "$BASE/connections/local-model" -H "Authorization: Bearer $TOKEN"
Next step
You created an agent and talked to it. Next, give your agent tools, such as a search tool that works over your own documents: