Azure AI Foundry 에이전트 서비스를 사용하면 사용자 지정 지침을 통해 요구 사항에 맞게 조정되고 코드 인터프리터 및 사용자 지정 함수와 같은 고급 도구로 보강된 AI 에이전트를 만들 수 있습니다.
필수 조건
- Azure 구독 – 무료로 만드세요.
- 계정 및 프로젝트를 만드는 개인에게 구독 범위에서 Azure AI 계정 소유자 역할이 있는지 확인합니다.
- 또는 구독 수준에서 기여자 또는 Cognitive Services 기여자 역할을 갖는 것도 이 요구 사항을 충족합니다.
중요합니다
Azure AI Foundry 포털은 현재 설정된 기본 에이전트만 지원합니다. 표준 에이전트 설정을 수행하려면 환경 설정 문서를 참조하여 자세한 내용을 알아보세요.
Azure AI Foundry 포털에서 Foundry 계정 및 프로젝트 만들기
Azure AI Foundry에서 계정 및 프로젝트를 만들려면 다음 단계를 수행합니다.
Azure AI 파운드리로 이동합니다. 프로젝트에 참여하고 있다면 페이지 왼쪽 상단에서 Azure AI 파운드리를 선택하여 홈페이지로 이동합니다.
가장 빠른 환경을 위해 에이전트 만들기 시작 흐름을 사용합니다. 에이전트 만들기를 클릭합니다.
프로젝트의 이름을 입력합니다. 기본값을 사용자 지정하려면 고급 옵션을 선택합니다.
선택하고생성합니다.
리소스가 프로비전될 때까지 기다립니다.
- 계정 및 프로젝트(계정의 자식 리소스)가 만들어집니다.
- gpt-4o 모델이 자동으로 배포됩니다.
- 기본 에이전트가 만들어집니다.
완료되면 에이전트 플레이그라운드에 직접 착륙하고 에이전트 만들기를 시작할 수 있습니다.
비고
에이전트를 구성하거나 만들려고 할 때 사용 권한 오류가 발생하는 경우 프로젝트에 Azure AI 사용자가 있는지 확인합니다.
| 참조 설명서 | 샘플 | 라이브러리 소스 코드 | 패키지(NuGet) |
필수 조건
- 에이전트 환경 설정
- SDK 또는 에이전트 플레이그라운드를 사용하여 에이전트를 만들거나 편집해야 하는 각 팀 구성원에게 Azure AI 사용자RBAC 역할 할당
- 이 역할은 프로젝트 범위에서 할당해야 합니다.
- 최소 필수 권한: agents/*/read, agents/*/action, agents/*/delete
에이전트 구성 및 실행
구성 요소 | 설명 |
---|---|
에이전트 | 도구와 함께 AI 모델을 사용하는 사용자 지정 AI. |
도구 | 도구는 대화 중에 에이전트가 안정적이고 정확하게 응답할 수 있는 기능을 확장하는 데 도움이 됩니다. 예를 들어, 사용자 정의 기술 자료에 연결하여 모델을 구축하거나, 웹 검색을 통해 최신 정보를 제공하는 것입니다. |
스레드 | 에이전트와 사용자 간의 대화 세션. 스레드는 메시지를 저장하고 자동으로 잘림을 처리하여 콘텐츠를 모델의 컨텍스트에 맞춥니다. |
메시지 | 에이전트나 사용자가 만든 메시지입니다. 메시지에는 텍스트, 이미지 및 기타 파일이 포함될 수 있습니다. 메시지는 스레드에 목록으로 저장됩니다. |
달려라 | 스레드의 콘텐츠에 따라 실행을 시작할 에이전트를 활성화합니다. 에이전트는 구성과 스레드의 메시지를 사용하여 모델과 도구를 호출하여 작업을 수행합니다. 실행의 일부로 에이전트는 스레드에 메시지를 추가합니다. |
.NET 콘솔 프로젝트를 만듭니다.
dotnet new console
프로젝트에 .NET 패키지를 설치합니다. 예를 들어, .NET CLI를 사용하는 경우 다음 명령을 실행합니다.
dotnet add package Azure.AI.Agents.Persistent
dotnet add package Azure.Identity
다음으로, API 요청을 인증하고 프로그램을 실행하려면 az login 명령을 사용하여 Azure 구독에 로그인합니다.
az login
다음 코드를 사용하여 에이전트를 만들고 실행합니다. 이 코드를 실행하려면 프로젝트의 엔드포인트를 가져와야 합니다. 이 문자열의 형식은 다음과 같습니다.
https://<AIFoundryResourceName>.services.ai.azure.com/api/projects/<ProjectName>
예를 들어, 엔드포인트는 다음과 같습니다.
https://myresource.services.ai.azure.com/api/projects/myproject
라는 ProjectEndpoint
appsetting 변수에서 이 엔드포인트를 설정합니다.
using Azure;
using Azure.AI.Agents.Persistent;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using System.Diagnostics;
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
var projectEndpoint = configuration["ProjectEndpoint"];
var modelDeploymentName = configuration["ModelDeploymentName"];
//Create a PersistentAgentsClient and PersistentAgent.
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
//Give PersistentAgent a tool to execute code using CodeInterpreterToolDefinition.
PersistentAgent agent = client.Administration.CreateAgent(
model: modelDeploymentName,
name: "My Test Agent",
instructions: "You politely help with math questions. Use the code interpreter tool when asked to visualize numbers.",
tools: [new CodeInterpreterToolDefinition()]
);
//Create a thread to establish a session between Agent and a User.
PersistentAgentThread thread = client.Threads.CreateThread();
//Ask a question of the Agent.
client.Messages.CreateMessage(
thread.Id,
MessageRole.User,
"Hi, Agent! Draw a graph for a line with a slope of 4 and y-intercept of 9.");
//Have Agent beging processing user's question with some additional instructions associated with the ThreadRun.
ThreadRun run = client.Runs.CreateRun(
thread.Id,
agent.Id,
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
//Poll for completion.
do
{
Thread.Sleep(TimeSpan.FromMilliseconds(500));
run = client.Runs.GetRun(thread.Id, run.Id);
}
while (run.Status == RunStatus.Queued
|| run.Status == RunStatus.InProgress
|| run.Status == RunStatus.RequiresAction);
//Get the messages in the PersistentAgentThread. Includes Agent (Assistant Role) and User (User Role) messages.
Pageable<PersistentThreadMessage> messages = client.Messages.GetMessages(
threadId: thread.Id,
order: ListSortOrder.Ascending);
//Display each message and open the image generated using CodeInterpreterToolDefinition.
foreach (PersistentThreadMessage threadMessage in messages)
{
foreach (MessageContent content in threadMessage.ContentItems)
{
switch (content)
{
case MessageTextContent textItem:
Console.WriteLine($"[{threadMessage.Role}]: {textItem.Text}");
break;
case MessageImageFileContent imageFileContent:
Console.WriteLine($"[{threadMessage.Role}]: Image content file ID = {imageFileContent.FileId}");
BinaryData imageContent = client.Files.GetFileContent(imageFileContent.FileId);
string tempFilePath = Path.Combine(AppContext.BaseDirectory, $"{Guid.NewGuid()}.png");
File.WriteAllBytes(tempFilePath, imageContent.ToArray());
client.Files.DeleteFile(imageFileContent.FileId);
ProcessStartInfo psi = new()
{
FileName = tempFilePath,
UseShellExecute = true
};
Process.Start(psi);
break;
}
}
}
//Clean up test resources.
client.Threads.DeleteThread(threadId: thread.Id);
client.Administration.DeleteAgent(agentId: agent.Id);
| 참조 설명서 | 샘플 | 라이브러리 소스 코드 | 패키지(PyPi) |
필수 조건
- 에이전트 환경 설정
- SDK 또는 에이전트 플레이그라운드를 사용하여 에이전트를 만들거나 편집해야 하는 각 팀 구성원에게 Azure AI 사용자RBAC 역할 할당
- 이 역할은 프로젝트 범위에서 할당해야 합니다.
- 최소 필수 권한: agents/*/read, agents/*/action, agents/*/delete
에이전트 구성 및 실행
구성 요소 | 설명 |
---|---|
에이전트 | 도구와 함께 AI 모델을 사용하는 사용자 지정 AI. |
도구 | 도구는 대화 중에 에이전트가 안정적이고 정확하게 응답할 수 있는 기능을 확장하는 데 도움이 됩니다. 예를 들어, 사용자 정의 기술 자료에 연결하여 모델을 구축하거나, 웹 검색을 통해 최신 정보를 제공하는 것입니다. |
스레드 | 에이전트와 사용자 간의 대화 세션. 스레드는 메시지를 저장하고 자동으로 잘림을 처리하여 콘텐츠를 모델의 컨텍스트에 맞춥니다. |
메시지 | 에이전트나 사용자가 만든 메시지입니다. 메시지에는 텍스트, 이미지 및 기타 파일이 포함될 수 있습니다. 메시지는 스레드에 목록으로 저장됩니다. |
달려라 | 스레드의 콘텐츠에 따라 실행을 시작할 에이전트를 활성화합니다. 에이전트는 구성과 스레드의 메시지를 사용하여 모델과 도구를 호출하여 작업을 수행합니다. 실행의 일부로 에이전트는 스레드에 메시지를 추가합니다. |
실행 단계 | 실행의 일환으로 에이전트가 수행한 단계의 자세한 목록입니다. 에이전트는 실행 중에 도구를 호출하거나 메시지를 만들 수 있습니다. 실행 단계를 검사하면 에이전트가 결과에 도달하는 방식을 이해할 수 있습니다. |
다음 명령을 실행하여 Python 패키지를 설치합니다.
pip install azure-ai-projects
pip install azure-identity
다음으로, API 요청을 인증하고 프로그램을 실행하려면 az login 명령을 사용하여 Azure 구독에 로그인합니다.
az login
다음 코드를 사용하여 에이전트를 만들고 실행합니다. 이 코드를 실행하려면 프로젝트의 엔드포인트를 가져와야 합니다. 이 문자열의 형식은 다음과 같습니다.
https://<AIFoundryResourceName>.services.ai.azure.com/api/projects/<ProjectName>
팁 (조언)
프로젝트에 대한 개요에서 Azure AI Foundry 포털의 라이브러리>아래 Azure AI Foundry에서 엔드포인트를 찾을 수 있습니다.
예를 들어, 엔드포인트는 다음과 같습니다.
https://myresource.services.ai.azure.com/api/projects/myproject
이 엔드포인트를 PROJECT_ENDPOINT
라는 환경 변수로 설정합니다.
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import CodeInterpreterTool
# Create an Azure AI Client from an endpoint, copied from your Azure AI Foundry project.
# You need to login to Azure subscription via Azure CLI and set the environment variables
project_endpoint = os.environ["PROJECT_ENDPOINT"] # Ensure the PROJECT_ENDPOINT environment variable is set
# Create an AIProjectClient instance
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
)
code_interpreter = CodeInterpreterTool()
with project_client:
# Create an agent with the Bing Grounding tool
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"], # Model deployment name
name="my-agent", # Name of the agent
instructions="You are a helpful agent", # Instructions for the agent
tools=code_interpreter.definitions, # Attach the tool
)
print(f"Created agent, ID: {agent.id}")
# Create a thread for communication
thread = project_client.agents.threads.create()
print(f"Created thread, ID: {thread.id}")
# Add a message to the thread
message = project_client.agents.messages.create(
thread_id=thread.id,
role="user", # Role of the message sender
content="What is the weather in Seattle today?", # Message content
)
print(f"Created message, ID: {message['id']}")
# Create and process an agent run
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
print(f"Run finished with status: {run.status}")
# Check if the run failed
if run.status == "failed":
print(f"Run failed: {run.last_error}")
# Fetch and log all messages
messages = project_client.agents.messages.list(thread_id=thread.id)
for message in messages:
print(f"Role: {message.role}, Content: {message.content}")
# Delete the agent when done
project_client.agents.delete_agent(agent.id)
print("Deleted agent")
| 참조 설명서 | 샘플 | 라이브러리 소스 코드 | 패키지(npm) |
필수 조건
- 에이전트 환경 설정
- SDK 또는 에이전트 플레이그라운드를 사용하여 에이전트를 만들거나 편집해야 하는 각 팀 구성원에게 Azure AI 사용자RBAC 역할 할당
- 이 역할은 프로젝트 범위에서 할당해야 합니다.
- 최소 필수 권한: agents/*/read, agents/*/action, agents/*/delete
에이전트 구성 및 실행
구성 요소 | 설명 |
---|---|
에이전트 | 도구와 함께 AI 모델을 사용하는 사용자 지정 AI입니다. |
도구 | 도구는 대화 중에 에이전트가 안정적이고 정확하게 응답할 수 있는 기능을 확장하는 데 도움이 됩니다. 예를 들어, 사용자 정의 기술 자료에 연결하여 모델을 구축하거나, 웹 검색을 통해 최신 정보를 제공하는 것입니다. |
스레드 | 에이전트와 사용자 간의 대화 세션. 스레드는 메시지를 저장하고 자동으로 잘림을 처리하여 콘텐츠를 모델의 컨텍스트에 맞춥니다. |
메시지 | 에이전트나 사용자가 만든 메시지입니다. 메시지에는 텍스트, 이미지 및 기타 파일이 포함될 수 있습니다. 메시지는 스레드에 목록으로 저장됩니다. |
달려라 | 스레드의 콘텐츠에 따라 실행을 시작할 에이전트를 활성화합니다. 에이전트는 구성과 스레드의 메시지를 사용하여 모델과 도구를 호출하여 작업을 수행합니다. 실행의 일부로 에이전트는 스레드에 메시지를 추가합니다. |
실행 단계 | 실행의 일환으로 에이전트가 수행한 단계의 자세한 목록입니다. 에이전트는 실행 중에 도구를 호출하거나 메시지를 만들 수 있습니다. 실행 단계를 검사하면 에이전트가 결과에 도달하는 방식을 이해할 수 있습니다. |
이 코드의 키 개체는 다음과 같습니다.
먼저, 다음을 실행하여 새 프로젝트를 초기화합니다.
npm init -y
다음 명령을 실행하여 필요한 npm 패키지를 설치합니다.
npm install @azure/ai-agents @azure/identity
npm install dotenv
다음으로, API 요청을 인증하고 프로그램을 실행하려면 az login 명령을 사용하여 Azure 구독에 로그인합니다.
az login
다음 코드를 사용하여 데이터의 CSV 파일을 업로드한 다음 해당 데이터에서 가로 막대형 차트를 생성하는 에이전트를 만들고 실행합니다. 이 코드를 실행하려면 프로젝트의 엔드포인트를 가져와야 합니다. 이 문자열의 형식은 다음과 같습니다.
https://<AIFoundryResourceName>.services.ai.azure.com/api/projects/<ProjectName>
팁 (조언)
프로젝트에 대한 개요에서 엔드포인트를 Azure AI Foundry 포털의 라이브러리 아래 Azure AI Foundry에서 찾을 수 있습니다.
예를 들어 엔드포인트는 다음과 같습니다.
https://myresource.services.ai.azure.com/api/projects/myproject
이 엔드포인트를 PROJECT_ENDPOINT
파일에서 .env
라는 이름의 환경 변수로 설정합니다.
중요합니다
- 이 빠른 시작 코드는 중요한 구성에 환경 변수를 사용합니다.
.env
가.env
파일에 나열되어 있는지 확인하여.gitignore
파일을 버전 제어에 커밋하지 마세요. - 참고: 실수로 중요한 정보를 유출한 경우 해당 자격 증명이 손상된 것으로 간주하고 즉시 회전합니다.
다음으로 파일을 만들고 index.js
다음 코드를 붙여넣습니다.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service.
*
* @summary demonstrates how to use agent operations with code interpreter.
*/
// @ts-nocheck
import type {
MessageDeltaChunk,
MessageDeltaTextContent,
MessageImageFileContent,
MessageTextContent,
ThreadRun,
} from "@azure/ai-agents";
import {
RunStreamEvent,
MessageStreamEvent,
DoneEvent,
ErrorEvent,
AgentsClient,
isOutputOfType,
ToolUtility,
} from "@azure/ai-agents";
import { DefaultAzureCredential } from "@azure/identity";
import * as fs from "fs";
import path from "node:path";
import "dotenv/config";
const projectEndpoint = process.env["PROJECT_ENDPOINT"] || "<project endpoint>";
const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o";
export async function main(): Promise<void> {
// Create an Azure AI Client
const client = new AgentsClient(projectEndpoint, new DefaultAzureCredential());
// Upload file and wait for it to be processed
const filePath = "./data/nifty500QuarterlyResults.csv";
const localFileStream = fs.createReadStream(filePath);
const localFile = await client.files.upload(localFileStream, "assistants", {
fileName: "myLocalFile",
});
console.log(`Uploaded local file, file ID : ${localFile.id}`);
// Create code interpreter tool
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]);
// Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment
const agent = await client.createAgent(modelDeploymentName, {
name: "my-agent",
instructions: "You are a helpful agent",
tools: [codeInterpreterTool.definition],
toolResources: codeInterpreterTool.resources,
});
console.log(`Created agent, agent ID: ${agent.id}`);
// Create a thread
const thread = await client.threads.create();
console.log(`Created thread, thread ID: ${thread.id}`);
// Create a message
const message = await client.messages.create(
thread.id,
"user",
"Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?",
);
console.log(`Created message, message ID: ${message.id}`);
// Create and execute a run
const streamEventMessages = await client.runs.create(thread.id, agent.id).stream();
for await (const eventMessage of streamEventMessages) {
switch (eventMessage.event) {
case RunStreamEvent.ThreadRunCreated:
console.log(`ThreadRun status: ${(eventMessage.data as ThreadRun).status}`);
break;
case MessageStreamEvent.ThreadMessageDelta:
{
const messageDelta = eventMessage.data as MessageDeltaChunk;
messageDelta.delta.content.forEach((contentPart) => {
if (contentPart.type === "text") {
const textContent = contentPart as MessageDeltaTextContent;
const textValue = textContent.text?.value || "No text";
console.log(`Text delta received:: ${textValue}`);
}
});
}
break;
case RunStreamEvent.ThreadRunCompleted:
console.log("Thread Run Completed");
break;
case ErrorEvent.Error:
console.log(`An error occurred. Data ${eventMessage.data}`);
break;
case DoneEvent.Done:
console.log("Stream completed.");
break;
}
}
// Delete the original file from the agent to free up space (note: this does not delete your version of the file)
await client.files.delete(localFile.id);
console.log(`Deleted file, file ID : ${localFile.id}`);
// Print the messages from the agent
const messagesIterator = client.messages.list(thread.id);
const messagesArray = [];
for await (const m of messagesIterator) {
messagesArray.push(m);
}
console.log("Messages:", messagesArray);
// Get most recent message from the assistant
// Get most recent message from the assistant
const assistantMessage = messagesArray.find((msg) => msg.role === "assistant");
if (assistantMessage) {
// Look for an image file in the assistant's message
const imageFileOutput = assistantMessage.content.find(content =>
content.type === "image_file" && content.imageFile?.fileId);
if (imageFileOutput) {
try {
// Save the newly created file
console.log(`Saving new files...`);
const imageFile = imageFileOutput.imageFile.fileId;
const imageFileName = path.resolve(
"./data/" + (await client.files.get(imageFile)).filename + "ImageFile.png",
);
console.log(`Image file name : ${imageFileName}`);
const fileContent = await client.files.getContent(imageFile).asNodeStream();
if (fileContent && fileContent.body) {
const chunks = [];
for await (const chunk of fileContent.body) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
}
const buffer = Buffer.concat(chunks);
fs.writeFileSync(imageFileName, buffer);
console.log(`Successfully saved image to ${imageFileName}`);
} else {
console.error("No file content available in the response");
}
} catch (error) {
console.error("Error saving image file:", error);
}
} else {
console.log("No image file found in assistant's message");
}
} else {
console.log("No assistant message found");
}
// Iterate through messages and print details for each annotation
console.log(`Message Details:`);
messagesArray.forEach((m) => {
console.log(`File Paths:`);
console.log(`Type: ${m.content[0].type}`);
if (isOutputOfType<MessageTextContent>(m.content[0], "text")) {
const textContent = m.content[0] as MessageTextContent;
console.log(`Text: ${textContent.text.value}`);
}
console.log(`File ID: ${m.id}`);
// firstId and lastId are properties of the paginator, not the messages array
// Removing these references as they don't exist in this context
});
// Delete the agent once done
await client.deleteAgent(agent.id);
console.log(`Deleted agent, agent ID: ${agent.id}`);
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});
를 사용하여 코드를 실행합니다 node index.js
. 이 코드는 업로드된 CSV 파일에서 TRANSPORTATION 섹터의 영업이익을 나타내는 막대형 차트 PNG 이미지 파일을 생성하고 그리고 그 파일을 제공했습니다. 전체 샘플 소스 코드를 사용할 수 있습니다.
| 참조 설명서 |
필수 조건
- 에이전트 환경 설정
- SDK 또는 에이전트 플레이그라운드를 사용하여 에이전트를 만들거나 편집해야 하는 각 팀 구성원에게 Azure AI 사용자RBAC 역할 할당
- 이 역할은 프로젝트 범위에서 할당해야 합니다.
- 최소 필수 권한: agents/*/read, agents/*/action, agents/*/delete
에이전트 구성 및 실행
구성 요소 | 설명 |
---|---|
에이전트 | 도구와 함께 AI 모델을 사용하는 사용자 지정 AI. |
도구 | 도구는 대화 중에 에이전트가 안정적이고 정확하게 응답할 수 있는 기능을 확장하는 데 도움이 됩니다. 예를 들어, 사용자 정의 기술 자료에 연결하여 모델을 구축하거나, 웹 검색을 통해 최신 정보를 제공하는 것입니다. |
스레드 | 에이전트와 사용자 간의 대화 세션. 스레드는 메시지를 저장하고 자동으로 잘림을 처리하여 콘텐츠를 모델의 컨텍스트에 맞춥니다. |
메시지 | 에이전트나 사용자가 만든 메시지입니다. 메시지에는 텍스트, 이미지 및 기타 파일이 포함될 수 있습니다. 메시지는 스레드에 목록으로 저장됩니다. |
달려라 | 스레드의 콘텐츠에 따라 실행을 시작할 에이전트를 활성화합니다. 에이전트는 구성과 스레드의 메시지를 사용하여 모델과 도구를 호출하여 작업을 수행합니다. 실행의 일부로 에이전트는 스레드에 메시지를 추가합니다. |
실행 단계 | 실행의 일환으로 에이전트가 수행한 단계의 자세한 목록입니다. 에이전트는 실행 중에 도구를 호출하거나 메시지를 만들 수 있습니다. 실행 단계를 검사하면 에이전트가 결과에 도달하는 방식을 이해할 수 있습니다. |
API 호출 정보
API 요청을 인증하려면 az login 명령을 사용하여 Azure 구독에 로그인합니다.
az login
다음으로, API 호출에 대한 권한을 제공하기 위해 Entra ID 토큰을 가져와야 합니다. CLI 명령을 사용하여 토큰을 가져옵니다.
az account get-access-token --resource 'https://ai.azure.com' | jq -r .accessToken | tr -d '"'
액세스 토큰을 AGENT_TOKEN
이라는 환경 변수로 설정합니다.
Azure AI Foundry 에이전트 서비스에 대한 REST API 호출을 성공적으로 수행하려면 아래와 같이 엔드포인트를 사용해야 합니다.
https://<your_ai_service_name>.services.ai.azure.com/api/projects/<your_project_name>
예를 들어, 엔드포인트는 다음과 같습니다.
https://exampleaiservice.services.ai.azure.com/api/projects/project
이 엔드포인트를 AZURE_AI_FOUNDRY_PROJECT_ENDPOINT
라는 환경 변수로 설정합니다.
비고
- 매개 변수의 경우
api-version
GA API 버전은2025-05-01
최신 미리 보기 API 버전입니다2025-05-15-preview
. 미리 보기에 있는 도구에 미리 보기 API를 사용해야 합니다. - API 버전을 환경 변수(예: .)로
$API_VERSION
만드는 것이 좋습니다.
에이전트 만들기
비고
Azure AI 에이전트 서비스를 사용하면 model
매개 변수에 모델 배포 이름이 필요합니다. 모델 배포 이름이 기본 모델 이름과 다른 경우 코드를 "model": "{your-custom-model-deployment-name}"
(으)로 조정합니다.
curl --request POST \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"instructions": "You are a helpful agent.",
"name": "my-agent",
"tools": [{"type": "code_interpreter"}],
"model": "gpt-4o-mini"
}'
스레드 만들기
curl --request POST \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d ''
스레드에 사용자 질문 추가
curl --request POST \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": "I need to solve the equation `3x + 11 = 14`. Can you help me?"
}'
스레드 실행
curl --request POST \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"assistant_id": "asst_abc123",
}'
실행 상태 검색
curl --request GET \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN"
에이전트 응답 검색
curl --request GET \
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
-H "Authorization: Bearer $AGENT_TOKEN"