メインコンテンツまでスキップ

Azure OpenAI プロバイダー

Azure OpenAI プロバイダーは、Reveal SDK AI を Azure の OpenAI Service と統合し、エンタープライズグレードのセキュリティとコンプライアンスを備えた独自の Azure サブスクリプションにデプロイされた OpenAI モデルを使用できます。

インストール

Azure OpenAI プロバイダーの NuGet パッケージをインストールします:

dotnet add package Reveal.Sdk.AI.AzureOpenAI

設定

基本セットアップ

Program.cs で Azure OpenAI プロバイダーを追加します:

using Reveal.Sdk;
using Reveal.Sdk.AI;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers().AddReveal();

builder.Services.AddRevealAI()
.AddAzureOpenAI(options =>
{
options.ApiKey = builder.Configuration["RevealAI:AzureOpenAI:ApiKey"];
options.Endpoint = "https://your-resource-name.openai.azure.com/";
options.DeploymentName = "gpt-4o";
});

var app = builder.Build();
app.MapControllers();
app.Run();

appsettings.json の使用

プロバイダーは RevealAI:AzureOpenAI 設定セクションに自動的にバインドされます:

appsettings.json
{
"RevealAI": {
"AzureOpenAI": {
"ApiKey": "your-azure-api-key",
"Endpoint": "https://your-resource-name.openai.azure.com/",
"DeploymentName": "gpt-4o",
"Temperature": 0.0,
"MaxTokens": 4096
}
}
}

設定バインディングを使用する場合、コードでのオプション設定は不要です:

builder.Services.AddRevealAI()
.AddAzureOpenAI();

オプション

プロパティデフォルト説明
ApiKeystring""必須。 Azure OpenAI API キー。
Endpointstring""必須。 Azure OpenAI エンドポイント URL(例: https://your-resource-name.openai.azure.com/)。
DeploymentNamestring""必須。 Azure でのモデルデプロイメント名。
Temperaturefloat?0.0ランダム性を制御(0.0 〜 2.0)。低い値ほど決定論的です。
MaxTokensint?4096レスポンスで生成するトークンの最大数。
TopPfloat?1.0Nucleus サンプリングパラメータ。
ReasoningEffortstring?null推論モデル(o3、o4 など)の推論努力レベル。

Azure セットアップの前提条件

Azure OpenAI プロバイダーを使用する前に、以下が必要です:

  1. Azure OpenAI Service にアクセスできる Azure サブスクリプション
  2. Azure ポータルで作成された Azure OpenAI リソース
  3. そのリソース内の モデルデプロイメント(例: GPT-4o、GPT-4.1)
  4. Azure ポータルからの API キーエンドポイント

API キーとエンドポイントは、Azure ポータルの Azure OpenAI リソースの Keys and Endpoint セクションで確認できます。

推論モデル

OpenAI プロバイダーと同様に、Azure OpenAI プロバイダーも推論モデルのデプロイメント(o1、o3、o4、gpt-5)を自動的に検出し、動作を調整します:

  • 推論モデルでは Temperature が無効化されます
  • 推論努力を設定できます
builder.Services.AddRevealAI()
.AddAzureOpenAI(options =>
{
options.ApiKey = builder.Configuration["RevealAI:AzureOpenAI:ApiKey"];
options.Endpoint = "https://your-resource.openai.azure.com/";
options.DeploymentName = "o3";
options.ReasoningEffort = "Medium";
});
API キーをコミットしないでください

API キーをソースコントロールにコミットしないでください。常に環境変数、User Secrets、または安全なキー管理サービスを使用してください。