Azure AI 推論エンドポイントを使用すると、お客様が、同じ認証とスキーマによる 1 つのエンドポイントを使用して、リソースにデプロイされたモデルの推論を生成できるようになります。 このエンドポイントは、Azure AI モデル推論のすべてのモデルがサポートしている Azure AI モデル推論 API に従います。 これは、次のモダリティをサポートしています。
テキスト埋め込み
画像埋め込み
チャット入力候補
エンドポイントの URL と資格情報は、[概要] セクションで確認できます。
ルーティング
推論エンドポイントは、要求の内部の name パラメーターをデプロイの名前と照合することで、要求を特定のデプロイにルーティングします。 つまり、"デプロイは、特定の構成下で特定のモデルのエイリアスとして機能する" ということです。 この柔軟性により、特定のモデルをサービスで複数回デプロイできますが、必要に応じて異なる構成でデプロイできます。
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
model = ChatCompletionsClient(
endpoint="https://<resource>.services.ai.azure.com/models",
credential=AzureKeyCredential(os.environ["AZUREAI_ENDPOINT_KEY"]),
)
import ModelClient from "@azure-rest/ai-inference";
import { isUnexpected } from "@azure-rest/ai-inference";
import { AzureKeyCredential } from "@azure/core-auth";
const client = new ModelClient(
"https://<resource>.services.ai.azure.com/models",
new AzureKeyCredential(process.env.AZUREAI_ENDPOINT_KEY)
);
ChatCompletionsClient client = new ChatCompletionsClient(
new Uri("https://<resource>.services.ai.azure.com/models"),
new AzureKeyCredential(Environment.GetEnvironmentVariable("AZURE_INFERENCE_CREDENTIAL"))
);
from azure.ai.inference.models import SystemMessage, UserMessage
response = client.complete(
messages=[
SystemMessage(content="You are a helpful assistant."),
UserMessage(content="Explain Riemann's conjecture in 1 paragraph"),
],
model="mistral-large"
)
print(response.choices[0].message.content)
var messages = [
{ role: "system", content: "You are a helpful assistant" },
{ role: "user", content: "Explain Riemann's conjecture in 1 paragraph" },
];
var response = await client.path("/chat/completions").post({
body: {
messages: messages,
model: "mistral-large"
}
});
console.log(response.choices[0].message.content)
requestOptions = new ChatCompletionsOptions()
{
Messages = {
new ChatRequestSystemMessage("You are a helpful assistant."),
new ChatRequestUserMessage("Explain Riemann's conjecture in 1 paragraph")
},
Model = "mistral-large"
};
response = client.Complete(requestOptions);
Console.WriteLine($"Response: {response.Value.Content}");
List<ChatRequestMessage> chatMessages = new ArrayList<>();
chatMessages.add(new ChatRequestSystemMessage("You are a helpful assistant"));
chatMessages.add(new ChatRequestUserMessage("Explain Riemann's conjecture in 1 paragraph"));
ChatCompletions chatCompletions = client.complete(new ChatCompletionsOptions(chatMessages));
for (ChatChoice choice : chatCompletions.getChoices()) {
ChatResponseMessage message = choice.getMessage();
System.out.println("Response:" + message.getContent());
}
Request
POST https://<resource>.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview
Authorization: Bearer <bearer-token>
Content-Type: application/json
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Explain Riemann's conjecture in 1 paragraph"
}
],
"model": "mistral-large"
}
ヒント
デプロイのルーティングでは、大文字と小文字は区別されません。
SDK
Azure AI モデル推論エンドポイントは、Azure AI 推論 SDK、Azure AI Foundry SDK、Azure OpenAI SDKなどの複数の SDK でサポートされており、これらは複数の言語で利用できます。 LangChain、LangGraph、Llama-Index、Semantic Kernel、AG2 などの一般的なフレームワークでも、複数の統合がサポートされています。 詳細については、サポートされているプログラミング言語と SDK を参照してください。
Azure OpenAI 推論エンドポイント
AI サービスにデプロイされている Azure OpenAI モデルでは、Azure OpenAI API もサポートされています。 この API は、OpenAI モデルのすべての機能を公開し、アシスタント、スレッド、ファイル、バッチ推論などの追加機能をサポートします。