이 문서에서는 응답 API를 사용하여 Microsoft AI, DeepSeek 및 Grok 모델과 같은 Foundry 모델에 대한 텍스트 응답을 생성하는 방법을 설명합니다. 응답 API 사용을 지원하는 Foundry 모델의 전체 목록은 지원되는 Foundry 모델을 참조하세요.
필수 구성 요소
애플리케이션에서 배포된 모델에서 응답 API를 사용하려면 다음이 필요합니다.
AI 모델 시작 키트 사용
이 문서의 코드 조각은 AI 모델 시작 키트에서 가져온 것입니다. 이 시작 키트를 사용하여 응답 API와 함께 안정적인 OpenAI 라이브러리를 사용하여 Foundry 모델을 호출하는 데 필요한 완전한 클라우드 인프라 및 코드를 빠르게 시작할 수 있습니다.
응답 API를 사용하여 텍스트 생성
이 섹션의 코드를 사용하여 Foundry 모델에 대한 응답 API 호출을 수행합니다. 코드 샘플에서 모델을 사용할 클라이언트를 만든 다음 기본 요청을 보냅니다.
팁
Foundry 포털에서 모델을 배포할 때 배포 이름을 할당합니다. API 호출의 매개 변수에 이 배포 이름(모델 카탈로그 ID 아님)을 model 사용합니다.
Azure ID 클라이언트 라이브러리를 포함하여 라이브러리를 설치합니다.
pip install azure-identity
pip install -U openai
다음 코드를 사용하여 프로젝트 경로에서 OpenAI 클라이언트 개체를 구성하고, 배포를 지정하고, 응답을 생성합니다.
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
from openai import OpenAI
project_endpoint = "https://YOUR-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR_PROJECT_NAME"
# Build the base URL: project_endpoint + /openai/v1 (no api-version needed)
base_url = project_endpoint.rstrip("/") + "/openai/v1"
# get_bearer_token_provider returns a callable; call it to get automatic refresh of the token string
credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(credential, "https://ai.azure.com/.default")
client = OpenAI(
base_url=base_url,
api_key=token_provider(),
)
response = client.responses.create(
model="DeepSeek-R1-0528", # Replace with your deployment name, not the model ID
input="What are the top 3 benefits of cloud computing? Be concise.",
max_output_tokens=500,
)
print(f"Response: {response.output_text}")
print(f"Status: {response.status}")
print(f"Output tokens: {response.usage.output_tokens}")
Azure ID 클라이언트 라이브러리를 설치합니다.
dotnet add package Azure.Identity
dotnet add package OpenAI
다음 코드를 사용하여 프로젝트 경로에서 OpenAI 클라이언트 개체를 구성하고, 배포를 지정하고, 응답을 생성합니다.
using Azure.Identity;
using OpenAI;
using OpenAI.Responses;
var deploymentName = "DeepSeek-R1-0528"; // Replace with your deployment name, not the model ID
var project_endpoint = "https://YOUR-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR_PROJECT_NAME";
// Get EntraID token for keyless auth
var credential = new DefaultAzureCredential();
var token = await credential.GetTokenAsync(
new Azure.Core.TokenRequestContext(["https://ai.azure.com/.default"])
);
// Standard OpenAI client — no AzureOpenAI wrapper (no api-version needed with /v1 path)
var baseUrl = project_endpoint.TrimEnd('/') + "/openai/v1";
var client = new OpenAIClient(
new ApiKeyCredential(token.Token),
new OpenAIClientOptions { Endpoint = new Uri(baseUrl) });
// GetResponsesClient takes no parameter; model goes in CreateResponseOptions
var responseClient = client.GetResponsesClient(deploymentName);
var result = await responseClient.CreateResponseAsync(new CreateResponseOptions(
[ResponseItem.CreateUserMessageItem("What are the top 3 benefits of cloud computing? Be concise.")])
{ MaxOutputTokenCount = 500 }
);
Console.WriteLine($"Response: {result.Value.GetOutputText()}");
Console.WriteLine($"Status: {result.Value.Status}");
Console.WriteLine($"Output tokens: {result.Value.Usage.OutputTokenCount}");
DefaultAzureCredential 사용하기 전에 Azure ID 클라이언트 라이브러리를 설치합니다.
npm install @azure/identity
npm install openai
다음 코드를 사용하여 프로젝트 경로에서 OpenAI 클라이언트 개체를 구성하고, 배포를 지정하고, 응답을 생성합니다.
import OpenAI from "openai";
import { DefaultAzureCredential } from "@azure/identity";
async function getToken(): Promise<string> {
const credential = new DefaultAzureCredential();
const tokenResponse = await credential.getToken(
"https://ai.azure.com/.default"
);
return tokenResponse.token;
}
async function main() {
const projectEndpoint = "https://YOUR-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR_PROJECT_NAME";
const deploymentName = "DeepSeek-R1-0528"; // Replace with your deployment name, not the model ID
const baseURL = projectEndpoint.replace(/\/+$/, "") + "/openai/v1";
const token = await getToken();
const client = new OpenAI({
baseURL,
apiKey: token,
});
const response = await client.responses.create({
model: deploymentName,
input: "What are the top 3 benefits of cloud computing? Be concise.",
max_output_tokens: 500,
});
console.log(`Response: ${response.output_text}`);
console.log(`Status: ${response.status}`);
console.log(`Output tokens: ${response.usage?.output_tokens}`);
}
main();
Microsoft Entra ID 인증하려면 몇 가지 초기 설정이 필요합니다. 먼저 Azure ID 클라이언트 라이브러리를 설치합니다. 이 라이브러리를 설치하는 방법에 대한 자세한 내용은 Java 대한 Azure ID 클라이언트 라이브러리를 참조하세요.
Azure ID 클라이언트 라이브러리를 추가합니다.
<dependencies>
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>4.22.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.15.4</version>
</dependency>
</dependencies>
설치 후 사용할 자격 증명 azure.identity 유형을 선택합니다. 예를 들어 클라이언트를 인증하는 데 사용합니다 DefaultAzureCredential .
DefaultAzureCredential 는 실행 중인 환경에서 사용할 가장 적합한 자격 증명을 찾기 때문에 가장 쉬운 옵션입니다.
다음 코드를 사용하여 프로젝트 경로에서 OpenAI 클라이언트 개체를 구성하고, 배포를 지정하고, 응답을 생성합니다.
import com.azure.core.credential.TokenRequestContext;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
public class Sample {
public static void main(String[] args) {
String endpoint = "https://YOUR-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR_PROJECT_NAME";
String deploymentName = "DeepSeek-R1-0528"; // Replace with your deployment name, not the model ID
// Get EntraID token for keyless auth
var credential = new DefaultAzureCredentialBuilder().build();
var context = new TokenRequestContext().addScopes("https://ai.azure.com/.default");
String token = credential.getToken(context).block().getToken();
// Standard OpenAI client — no Azure wrapper
// Java SDK uses /openai/v1 path (no api-version needed; SDK manages versioning internally)
String baseUrl = endpoint.replaceAll("/+$", "") + "/openai/v1";
OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl(baseUrl)
.apiKey(token)
.build();
var response = client.responses().create(
ResponseCreateParams.builder()
.model(deploymentName)
.input("What are the top 3 benefits of cloud computing? Be concise.")
.maxOutputTokens(500)
.build()
);
System.out.printf("Response: %s%n", response.outputText());
System.out.printf("Status: %s%n", response.status());
response.usage().ifPresent(u ->
System.out.printf("Output tokens: %d%n", u.outputTokens()));
}
}
샘플을 실행하기 전에 필요한 Go 모듈을 설치합니다.
go get github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1
go get github.com/openai/openai-go/v3 v3.22.0
다음 코드를 사용하여 프로젝트 경로에서 OpenAI 클라이언트 개체를 구성하고, 배포를 지정하고, 응답을 생성합니다.
package main
import (
"context"
"fmt"
"os"
"strings"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/responses"
)
func main() {
projectEndpoint := "https://YOUR-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR_PROJECT_NAME"
deploymentName := "DeepSeek-R1-0528" // Replace with your deployment name, not the model ID
ctx := context.Background()
// Get EntraID token for keyless auth
credential, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create credential: %v\n", err)
os.Exit(1)
}
token, err := credential.GetToken(ctx, policy.TokenRequestOptions{
Scopes: []string{"https://ai.azure.com/.default"},
})
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get token: %v\n", err)
os.Exit(1)
}
// Standard OpenAI client — no Azure wrapper (no api-version needed with /v1 path)
baseURL := strings.TrimRight(projectEndpoint, "/") + "/openai/v1"
client := openai.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey(token.Token),
)
resp, err := client.Responses.New(ctx, responses.ResponseNewParams{
Model: deploymentName,
Input: responses.ResponseNewParamsInputUnion{
OfString: openai.String("What are the top 3 benefits of cloud computing? Be concise."),
},
MaxOutputTokens: openai.Int(500),
})
if err != nil {
fmt.Fprintf(os.Stderr, "API error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Response: %s\n", resp.OutputText())
fmt.Printf("Status: %s\n", resp.Status)
fmt.Printf("Output tokens: %d\n", resp.Usage.OutputTokens)
}
응답에는 모델 및 사용 메타데이터와 함께 생성된 텍스트가 포함됩니다.
지원되는 Foundry 모델
Foundry 모델 선택은 응답 API와 함께 사용할 수 있습니다.
Foundry 포털에서 지원되는 모델 보기
Foundry 포털에서 지원되는 모델의 전체 목록을 보려면 다음을 수행합니다.
-
Microsoft Foundry 로그인합니다.
New Foundry 토글이 설정되었는지 확인합니다. 이러한 단계는 Foundry(신규)를 참조합니다.
- 오른쪽 위 탐색에서 검색 을 선택한 다음 왼쪽 창의 모델을 선택합니다.
-
기능 드롭다운을 열고 에이전트 지원 필터를 선택합니다.
지원되는 모델 목록
이 섹션에서는 응답 API와 함께 사용할 수 있도록 지원되는 몇 가지 Foundry 모델을 나열합니다. 지원되는 Azure OpenAI 모델은 사용할 수 있는 Azure OpenAI 모델을 참조하세요.
Azure에서 판매하는 Foundry 모델:
-
MAI-DS-R1: 결정적이고 정밀도에 초점을 맞춘 추론입니다.
-
grok-4: 첨단 규모의 복잡한 다단계 문제 해결을 위한 추론입니다.
-
grok-4-fast-reasoning: 워크플로 자동화에 최적화된 가속 에이전트 추론입니다.
-
grok-4-fast-non-reasoning: 높은 처리량과 낮은 대기시간을 통한 생성 및 시스템 경로 지정.
-
grok-3: 복잡한 시스템 수준 워크플로에 대한 강력한 추론입니다.
-
grok-3-mini: 대화형 대용량 사용 사례에 최적화된 경량 모델입니다.
-
Llama-3.3-70B-Instruct: 엔터프라이즈 Q&A, 의사 결정 지원 및 시스템 오케스트레이션을 위한 다양한 모델입니다.
-
Llama-4-Maverick-17B-128E-Instruct-FP8: 빠르고 비용 효율적인 유추를 제공하는 FP8 최적화 모델입니다.
-
DeepSeek-V3-0324: 텍스트 및 이미지 간 다중 모드 이해
-
DeepSeek-V3.1: 향상된 다중 모드 추론 및 기반 검색.
-
DeepSeek-R1-0528: 고급 장문 및 다단계 논리적 추론.
-
gpt-oss-120b: 투명도 및 재현성을 지원하는 오픈 에코시스템 모델입니다.
일반적인 오류 문제 해결
| 오류 |
원인 |
해상도 |
| 401 권한 없음 |
잘못되었거나 만료된 자격 증명 |
DefaultAzureCredential 리소스에 Cognitive Services OpenAI 사용자 역할이 할당되었는지 확인합니다. |
| 404 찾을 수 없음 |
잘못된 엔드포인트 또는 배포 이름 |
엔드포인트 URL에 /api/projects/YOUR_PROJECT_NAME이 포함되고 배포 이름이 Foundry 포털과 일치하는지 확인합니다. |
| 400 모델이 지원되지 않음 |
모델은 응답 API를 지원하지 않습니다. |
지원되는 모델 목록을 확인하고 배포에서 호환되는 모델을 사용하는지 확인합니다. |
관련 콘텐츠