Microsoft Foundry のモデルで LangChain を使用する

langchain-azure-ai を使用して、Microsoft Foundry にデプロイされたモデルを呼び出す LangChain アプリをビルドします。 OpenAI 互換 API を使用したモデルは、AzureAIOpenAIApiChatModelで直接使用できます。デプロイされたAnthropic Claude モデルは、AzureAIAnthropicChatModelを使用して Anthropic Messages API を介して呼び出すことができます。また、デプロイされた決定モデルは、langchain_azure_ai.decisionsの分類子アダプターを使用して呼び出すことができます。 この記事では、チャット、決定、埋め込みクライアントの作成、モデルの非同期呼び出し、ベクター類似性検索の実行について説明します。

前提 条件

  • Azure サブスクリプション。 無料で作成できます。

  • Foundry プロジェクト。

  • Foundry プロジェクトにおける Foundry User ロール。

    重要

    Foundry RBAC ロールの名前が最近変更されました。 Foundry User, Foundry Owner, Foundry Account Owner、および Foundry Project Manager は、以前は、AZURE AI ユーザー、Azure AI 所有者、Azure AI アカウント所有者、および AZURE AI Project Manager という名前でした。 名前の変更がロールアウトされている間、以前の名前が表示される場合があります。ロール ID とコア アクセス許可は、名前の変更によって変更されません。

  • gpt-4.1やMistral-Large-3などの OpenAI と互換性のある API (および Claude の例を実行する場合は、claude-sonnet-4-6などのAnthropic Claude展開) をサポートするデプロイ済みチャット モデル。

  • Microsoft-Decision-1.1などのデプロイされた意思決定モデル (意思決定モデルの例を実行する場合は、langchain-azure-ai>=1.4.1が必要であり、Azure OpenAI Decisions にはlangchain-openai>=1.8.0も必要です)。

  • text-embedding-3-largeなど、デプロイされた埋め込みモデル。

  • Python 3.11 以降。

必要なパッケージをインストールします。

pip install -U langchain langchain-azure-ai azure-identity

重要

langchain-azure-aiは、新しい Microsoft Foundry SDK (v2) を使用します。 Foundry クラシックを使用している場合は、提供が終了した Azure AI Inference SDK を使用する langchain-azure-ai[v1] を使用してください。 詳細はこちら。

環境を構成する

次のいずれかの接続パターンを設定します。

  • Microsoft Entra IDを使用したプロジェクトのエンドポイント (推奨)。
  • API キーを使用したダイレクト エンドポイント。
import os

# Option 1: Project endpoint (recommended)
os.environ["FOUNDRY_PROJECT_ENDPOINT"] = (
	"https://<resource>.services.ai.azure.com/api/projects/<project>"
)

# Option 2: Direct OpenAI-compatible endpoint + API key
os.environ["OPENAI_BASE_URL"] = (
	"https://<resource>.services.ai.azure.com/openai/v1"
)
os.environ["OPENAI_API_KEY"] = "<your-api-key>"

このスニペットの機能: プロジェクト ベースまたは直接エンドポイント アクセス用に langchain-azure-ai モデル クラスによって使用される環境変数を定義します。

チャット モデルを使用する

次の init_chat_modelを使用して、モデルを簡単にインスタンス化できます。

from langchain.chat_models import init_chat_model

model = init_chat_model("azure_ai:gpt-4.1")

重要

init_chat_modelを使用するには、langchain>=1.2.13が必要です。 バージョンを更新できない場合は、クライアントを 直接構成します。

OpenAI 互換 API をサポートするすべての Foundry モデルをクライアントで使用できますが、最初に Foundry リソースにデプロイする必要があります。 project_endpoint (環境変数 FOUNDRY_PROJECT_ENDPOINT) を使用するには、認証とロール Foundry User のMicrosoft Entra IDが必要です。

このスニペットの機能:init_chat_model便利なメソッドを使用して、チャット モデル クライアントを作成します。 クライアントは、Foundry プロジェクト エンドポイントまたは環境で構成された直接エンドポイントを介して、指定されたモデルにルーティングされます。

参照:

セットアップを確認する

単純なモデル呼び出しを実行します。

response = model.invoke("Say hello")
response.pretty_print()
================================== Ai Message ==================================
Hello! 👋 How can I help you today?

このスニペットの機能: エンドポイント、認証、およびモデル のルーティングを確認するための基本的なプロンプトを送信します。

参照:

構成可能なモデル

configurable_fieldsを指定して、ランタイムで構成可能なモデルを作成することもできます。 model パラメーターを省略すると、既定で構成可能なフィールドになります。

from langchain.chat_models import init_chat_model
from azure.identity import DefaultAzureCredential

configurable_model = init_chat_model(
    model_provider="azure_ai", 
    temperature=0,
	credential=DefaultAzureCredential()
)


configurable_model.invoke(
    "what's your name",
    config={"configurable": {"model": "gpt-5-nano"}},  # Run with GPT-5-nano
).pretty_print()

configurable_model.invoke(
    "what's your name",
    config={"configurable": {"model": "Mistral-Large-3"}}, # Run with Mistral Large
).pretty_print()
================================== Ai Message ==================================

Hi! I'm ChatGPT, an AI assistant built by OpenAI. You can call me ChatGPT or just Assistant. How can I help you today?
================================== Ai Message ==================================

I don't have a name, but you can call me **Assistant** or anything you like! 😊 What can I help you with today?

このスニペットの機能: 呼び出し時にモデルを簡単に切り替える構成可能なモデル インスタンスを作成します。 model パラメーターはinit_chat_modelにないため、既定では構成可能なフィールドであり、invoke()で渡すことができます。 configurable_fieldsを構成することで、構成可能な他のフィールドを追加できます。

クライアントを直接構成する

また、 AzureAIOpenAIApiChatModel クラスを使用してチャット モデル クライアントを作成することもできます。

import os

from azure.identity import DefaultAzureCredential
from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel

model = AzureAIOpenAIApiChatModel(
	project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
	credential=DefaultAzureCredential(),
	model="Mistral-Large-3",
)

既定では、 AzureAIOpenAIApiChatModel は OpenAI Responses API を使用します。 この動作は、 use_responses_api=False渡すことで変更できます。

import os

from azure.identity import DefaultAzureCredential
from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel

model = AzureAIOpenAIApiChatModel(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
    model="Mistral-Large-3",
    use_responses_api=False
)

非同期呼び出しを実行する

アプリが ainvokeを使用してモデルを呼び出す場合は、非同期資格情報を使用します。 認証にMicrosoft Entra IDを使用する場合は、資格情報に対応する非同期実装を使用します。

import os

from azure.identity.aio import DefaultAzureCredential as DefaultAzureCredentialAsync
from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel

model = AzureAIOpenAIApiChatModel(
	project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
	credential=DefaultAzureCredentialAsync(),
	model="gpt-4.1",
)


async def main():
	response = await model.ainvoke("Say hello asynchronously")
	response.pretty_print()


import asyncio
asyncio.run(main())

ヒント

このコードを Jupyter ノートブックで実行する場合は、await main()ではなく、asyncio.run(main())を直接使用できます。

================================== Ai Message ==================================
Hello! 👋 How can I help you today?

このスニペットの機能: 非同期クライアントを作成し、 ainvokeを使用して非ブロッキング要求を実行します。

参照:

Anthropic Claude モデルを使用する

Microsoft Foundry にデプロイされた Claude モデルでは、OpenAI と互換性のある API ではなく、専用の/anthropic エンドポイントが使用されます。 AzureAIAnthropicChatModelを使用して、Microsoft Entra IDまたは API キー認証で呼び出します。

import os

from azure.identity import DefaultAzureCredential
from langchain_azure_ai.chat_models import AzureAIAnthropicChatModel

claude = AzureAIAnthropicChatModel(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
    model="claude-sonnet-4-6",  # your Claude deployment name
)

claude.invoke("Say hello").pretty_print()

このスニペットの機能:DefaultAzureCredentialを使用して Foundry プロジェクト エンドポイントからAnthropic チャット クライアントを作成し、デプロイされた Claude モデルにプロンプトを送信します。

endpointではなく、リソース project_endpointを直接渡すこともできます。

claude = AzureAIAnthropicChatModel(
    endpoint="https://<resource>.services.ai.azure.com",
    credential=DefaultAzureCredential(),
    model="claude-sonnet-4-6",  # your Claude deployment name
)

project_endpointとendpointの両方を省略した場合、AzureAIAnthropicChatModelは、AZURE_AI_PROJECT_ENDPOINT、FOUNDRY_PROJECT_ENDPOINT、ANTHROPIC_FOUNDRY_RESOURCE (my-resourceなどのベア Foundry リソース名、endpoint経由で完全な URL を渡す) をその順序で確認します。 credentialを省略すると、AzureAIAnthropicChatModelはOPENAI_API_KEYとANTHROPIC_API_KEYを無視し、既定ではDefaultAzureCredential()になります。 API キー認証の場合は、project_endpointまたはcredential="<your-api-key>"とともにendpointを渡します。 AzureAIAnthropicChatModel は使用しないでください。これは init_chat_model("azure_ai:...") ではなく AzureAIOpenAIApiChatModel に解決されるためです。

参照:

推論

多くのモデルでは、結論を得るために複数ステップの推論を実行できます。 これには、複雑な問題をより小さく、より管理しやすい手順に分割する必要があります。

from langchain.chat_models import init_chat_model

model = init_chat_model("azure_ai:DeepSeek-R1-0528")

for chunk in model.stream("Why do parrots have colorful feathers?"):
    reasoning_steps = [r for r in chunk.content_blocks if r["type"] == "reasoning"]
    print(reasoning_steps if reasoning_steps else chunk.text, end="")

print("\n")
Parrots have colorful feathers primarily due to a combination of evolutionary ...

参照:

サーバー側ツール

Foundry にデプロイされた OpenAI モデルは、サーバー側のツール呼び出しループをサポートします。モデルは、Web 検索、コード インタープリター、その他のツールと対話し、その結果を 1 回の会話ターンで分析できます。 モデルがツール サーバー側を呼び出す場合、応答メッセージの内容には、ツールの呼び出しと結果を表すコンテンツが含まれます。

重要

名前空間 langchain_azure_ai.tools.builtin のツールは、OpenAI モデルでのみサポートされます。

これらは、モデルの機能を拡張する OpenAI によって提供されるツールです。 サポートされているツールの完全な一覧については、 組み込みのツールを参照してください。

次の例は、Web 検索の使用方法を示しています。

from langchain.chat_models import init_chat_model
from langchain_azure_ai.tools.builtin import WebSearchTool
from azure.identity import DefaultAzureCredential

model = init_chat_model("azure_ai:gpt-4.1", credential=DefaultAzureCredential())
model_with_web_search = model.bind_tools([WebSearchTool()])

result = model_with_web_search.invoke("What is the current price of gold? Give me the answer in one sentence.")
result.content[-1]["text"]
As of today, March 24, 2026, the spot price of gold is approximately $4,397.80 per ounce. ([tradingeconomics.com](https://tradingeconomics.com/commodity/gold))

一部のツールでは、プロジェクト内の他のリソースの構成が必要になる場合があります。 azure-ai-projectsを使用してこれらのリソースを構成し、LangChain/LangGraph から参照します。

次の例は、ツールで使用する前にファイル ストアを構成する方法を示しています。

import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential

# Create clients to call Foundry API
project = AIProjectClient(
    endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
)
openai = project.get_openai_client()

# Create vector store and upload file
vector_store = openai.vector_stores.create(name="ProductInfoStore")
vector_store_id = vector_store.id

with open("product_info.md", "rb") as file_handle:
    vector_store_file = openai.vector_stores.files.upload_and_poll(
        vector_store_id=vector_store.id,
        file=file_handle,
    )

このスニペットの機能:モデルがそのファイルのコンテンツを後で検索できるように、Microsoft Foundry でファイルを使用してベクター ストアを設定します (これは次のコード ブロックのFileSearchToolで使用されます)。

from langchain_azure_ai.tools.builtin import FileSearchTool

model_with_tools = model.bind_tools([FileSearchTool(vector_store_ids=[vector_store.id])])

results = model_with_tools.invoke("Tell me about Contoso products")
print("Answer:", results.content[-1]["text"])
print("Annotations:", results.content[-1]["annotations"])
Answer: Contoso offers the following products:

1. **The widget**
   - Description: A high-quality widget that is perfect for all your widget needs.
   - Price: $19.99

2. **The gadget**
   - Description: An advanced gadget that offers exceptional performance and reliability.
   - Price: $49.99

These products are part of Contoso's main offerings as detailed in their product information documentation.
Annotations: [{'file_id': 'assistant-MvU5SEqUcUBumoLUV5BXxn', 'filename': 'product_info.md', 'type': 'file_citation', 'file_index': 395}]

エージェントで Foundry モデルを使用する

Foundry に接続されているモデルで create_agent を使用して、ReAct スタイルのエージェント ループを作成します。

from langchain.agents import create_agent

agent = create_agent(
    model="azure_ai:gpt-5.2", 
    system_prompt="You're an informational agent. Answer questions cheerfully.", 
)

response = agent.invoke({"messages": "what's your name?"})
response["messages"][-1].pretty_print()
================================== Ai Message ==================================

I’m ChatGPT, your AI assistant.

サーバー側ツールも使用できますが、 bind_toolsを呼び出す必要があります。

from langchain.chat_models import init_chat_model
from langchain.agents import create_agent
from langchain_azure_ai.tools.builtin import ImageGenerationTool

model = init_chat_model("azure_ai:gpt-5.2")
tools = [ImageGenerationTool(model="gpt-image-1.5", size="1024x1024")]
model_with_tools = model.bind_tools(tools)

agent = create_agent(
    model=model_with_tools,
    tools=tools,
    system_prompt="You're an informational agent. Answer questions with graphics.", 
)

ヒント

Foundry のイメージ生成ツールでは、 x-ms-oai-image-generation-deploymentヘッダーの一部として、イメージ生成用のモデル デプロイ名を渡す必要があります。 langchain-azure-aiを使用する場合、これは自動的に処理されます。 ただし、 langchain-openaiでこのツールを使用する場合は、ヘッダーを手動で渡す必要があります。

Note

LangGraph エージェント内で Responses API チャット モデルを使用する場合は、モデルに store=False を設定します ( init_chat_model("azure_ai:gpt-5.2", store=False) や AzureAIOpenAIApiChatModel(..., store=False)など)。 LangGraph は会話履歴をグラフ状態で管理するため、モデル側の応答ストレージを無効にすることで、ツール呼び出しターン間での再生エラーを回避できます。

意思決定モデルを使用する

デシジョン モデルは、名前付き分類の質問に対して構造化状態を評価し、確率と信頼度スコアを使用して型指定された回答を返します。 デシジョン モデル アダプターには langchain-azure-ai>=1.4.1が必要です。

Models Adapter API パス
Microsoftデシジョン モデル (Microsoft-Decision-1とMicrosoft-Decision-1.1で検証済み) AzureAIMicrosoftDecisionsClassifier /providers/microsoft/v1/systemone
Decisions API をサポートする Azure OpenAI モデル AzureAIOpenAIApiDecisionsClassifier (試験段階) /openai/v1/decisions

どちらのアダプターも、Runnable[ClassifierRequest, ClassifierResponse] と BaseDecisionModel をサポートする ainvoke である LangChain の invoke を実装します。 stateと名前を付けたquestionsの辞書を渡し、質問名で回答を読み取ります。

  • Noul: 条件が true (result.nouls) である確率。
  • Choice: 確率と信頼度を含む、2 つ以上の固定オプション (result.choices) からの選択。
  • Score: 確率と信頼度を含む、順序付けされたレベル (result.scores) に対する評価。

どちらのアダプターも、 Box の質問をサポートしていない。

Microsoft Decision デプロイを呼び出す

modelをご利用の Foundry デプロイ名に設定します。 project_endpointを渡す (またはAZURE_AI_PROJECT_ENDPOINT / FOUNDRY_PROJECT_ENDPOINTを設定する) と、両方のアダプターがリソース URL を派生させ、既定でDefaultAzureCredentialします。

import os

from langchain_azure_ai.decisions import (
    AzureAIMicrosoftDecisionsClassifier,
    Choice,
    Noul,
    Score,
)

decisions = AzureAIMicrosoftDecisionsClassifier(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    model="<your-decision-deployment>",
)

result = decisions.invoke(
    {
        "state": {"ticket": "I was charged twice for this order."},
        "questions": {
            "urgent": Noul(
                instructions="Does this ticket require immediate escalation?",
            ),
            "team": Choice(
                instructions="Which team should handle this ticket?",
                criteria={
                    "billing": "Payments and refunds",
                    "support": "Other requests",
                },
            ),
            "severity": Score(
                instructions="Rate customer impact from low to high.",
                criteria=["Low", "Medium", "High"],
            ),
        },
    }
)

print("Urgent probability:", result.nouls["urgent"].noul)
print("Team:", result.choices["team"].choice)
print("Severity:", result.scores["severity"].score)

このスニペットの機能:AzureAIMicrosoftDecisionsClassifierを使用して、1 つの要求のNoul、Choice、およびScoreの質問に対してサポート チケットを評価します。

Azure OpenAI の Decisions デプロイを呼び出す

AzureAIOpenAIApiDecisionsClassifier は試験的で、langchain-openai>=1.8.0 のベータ OpenAIClassifier を拡張したものです。 アダプターを切り替えると、要求と応答の形状は同じままです。

import os

from langchain_azure_ai.decisions import (
    AzureAIOpenAIApiDecisionsClassifier,
    Choice,
)

decisions = AzureAIOpenAIApiDecisionsClassifier(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    model="<your-openai-decisions-deployment>",
)

result = decisions.invoke(
    {
        "state": {"ticket": "I was charged twice for this order."},
        "questions": {
            "team": Choice(
                instructions="Which team should handle this ticket?",
                criteria={
                    "billing": "Payments and refunds",
                    "support": "Other requests",
                },
            )
        },
    }
)
print(result.choices["team"].choice)

このスニペットの機能: 同じ要求と応答インターフェイスを使用して、AzureAIOpenAIApiDecisionsClassifier を使用して同じサポート チケットを分類します。

Note

新しいコードで AzureAIOpenAIApiDecisionsClassifier を使用します。 AzureAIOpenAIApiDecisions は互換性エイリアスとして引き続き使用できます。

アダプターの違い

  • AzureAIMicrosoftDecisionsClassifier: テキスト、JSON オブジェクト、および JSON 配列を受け入れます。 LangChain メッセージの変換や画像アセットの送信は行われません。 API キー認証の場合は、キーを credentialとして渡します。 プロジェクトの URL 解決をスキップするには、パス サフィックス (https://<resource>.services.ai.azure.com など) を含まないベア Foundry リソースルート URL をendpointとして渡します。パスを渡すと、/providers/microsoft/v1/systemoneValueErrorが発生します。
  • AzureAIOpenAIApiDecisionsClassifier: 構築時に ExperimentalWarning を出力し、 Noul を Predicateにマップし、ルート メッセージ上の画像をサポートします (JSON 状態に埋め込まれたメディアは警告と共に破棄されます)。 質問に対する拒否は、要求全体に対して ModelRefusalError を発生させます。 project_endpointにはMicrosoft Entra IDが必要です。API キー認証の場合は、/openai/v1で終わるリソース endpointを渡し、キーをcredentialとして渡します。

参照:

埋め込みモデルを使用する

次の init_embeddingsを使用して、モデルを簡単にインスタンス化できます。

from langchain.embeddings import init_embeddings
from azure.identity import DefaultAzureCredential

embed_model = init_embeddings(
    "azure_ai:text-embedding-3-small",
    credential=DefaultAzureCredential(),
)

このスニペットの機能:init_embeddings便利なメソッドを使用して、埋め込みモデル クライアントを作成します。 init_chat_modelとは異なり、init_embeddingsは自動的にDefaultAzureCredentialにフォールバックしないため、資格情報を明示的に渡します。

OpenAI 互換 API をサポートするすべての Foundry モデルをクライアントで使用できますが、最初に Foundry リソースにデプロイする必要があります。 project_endpoint (環境変数 FOUNDRY_PROJECT_ENDPOINT) を使用するには、認証とロール Foundry User のMicrosoft Entra IDが必要です。

または、 AzureAIOpenAIApiEmbeddingsModelを使用して埋め込みクライアントを作成します。

import os

from azure.identity import DefaultAzureCredential
from langchain_azure_ai.embeddings import AzureAIOpenAIApiEmbeddingsModel

embed_model = AzureAIOpenAIApiEmbeddingsModel(
	project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
	credential=DefaultAzureCredential(),
	model="text-embedding-3-large",
)

直接エンドポイントと API キー認証の場合:

import os

from langchain_azure_ai.embeddings import AzureAIOpenAIApiEmbeddingsModel

embed_model = AzureAIOpenAIApiEmbeddingsModel(
	endpoint=os.environ["OPENAI_BASE_URL"],
	credential=os.environ["OPENAI_API_KEY"],
	model="text-embedding-3-large",
)

このスニペットの機能: ベクター検索、情報検索、およびランク付けワークフローの埋め込み生成を構成します。

参照:

例: ベクター ストアを使用して類似性検索を実行する

ローカル実験にはメモリ内ベクター ストアを使用します。

from langchain_core.documents import Document
from langchain_core.vectorstores import InMemoryVectorStore

vector_store = InMemoryVectorStore(embed_model)

documents = [
	Document(id="1", page_content="foo", metadata={"baz": "bar"}),
	Document(id="2", page_content="thud", metadata={"bar": "baz"}),
]

vector_store.add_documents(documents=documents)

results = vector_store.similarity_search(query="thud", k=1)
for doc in results:
	print(f"* {doc.page_content} [{doc.metadata}]")
* thud [{'bar': 'baz'}]

このスニペットの機能: ベクター ストアにサンプル ドキュメントを追加し、クエリの最も似たドキュメントを返します。

参照:

ログ記録を使用して要求をデバッグする

デバッグ ログ langchain_azure_ai 有効にして、要求フローを検査します。

import logging
import sys

logger = logging.getLogger("langchain_azure_ai")
logger.setLevel(logging.DEBUG)

handler = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter(
	"%(asctime)s:%(levelname)s:%(name)s:%(message)s"
)
handler.setFormatter(formatter)
logger.addHandler(handler)

このスニペットの機能:エンドポイントまたはペイロードの問題のトラブルシューティングに役立つ詳細な SDK ログを出力するように、Pythonログを構成します。

参照:

環境変数リファレンス

次の環境変数を構成できます。 これらの値は、オブジェクトを構築するときにも構成できます。

変数 役割 例 コンストラクターのパラメーター
AZURE_AI_PROJECT_ENDPOINT または FOUNDRY_PROJECT_ENDPOINT Foundry プロジェクト エンドポイント。 AZURE_AI_PROJECT_ENDPOINT は、両方が設定されている場合に優先されます。 Microsoft Entra ID認証は、全体的に推奨され、OpenAI 互換クラスに必要です (AzureAIAnthropicChatModelとAzureAIMicrosoftDecisionsClassifierは、project_endpointを含む API キーも受け入れます)。 https://contoso.services.ai.azure.com/api/projects/my-project project_endpoint
AZURE_AI_OPENAI_ENDPOINT OpenAI と互換性のある直接エンドポイントは、 endpointとして逐語的に使用されます。 AZURE_OPENAI_ENDPOINTよりも優先されます。 https://contoso.services.ai.azure.com/openai/v1 endpoint
AZURE_OPENAI_ENDPOINT ルート Azure OpenAI リソース URL。 /openai/v1 は自動的に追加され、 endpointとして使用されます。 https://contoso.openai.azure.com endpoint
OPENAI_BASE_URL モデル呼び出しに使用される OpenAI 互換の直接エンドポイント。 https://contoso.services.ai.azure.com/openai/v1 endpoint
OPENAI_API_KEY または AZURE_OPENAI_API_KEY キーベースの認証に OPENAI_BASE_URL、 AZURE_AI_OPENAI_ENDPOINT、または AZURE_OPENAI_ENDPOINT で使用される API キー。 AzureAIOpenAIApiChatModel は OPENAI_API_KEYを読み取り、 AzureAIOpenAIApiDecisionsClassifier は AZURE_OPENAI_API_KEYを読み取ります。 <your-api-key> credential
AZURE_OPENAI_DEPLOYMENT_NAME Foundry または OpenAI リソース内のモデルのデプロイ名。 Foundry ポータルで名前を確認します。デプロイ名は、使用される基になるモデルとは異なる場合があります。 OpenAI 互換 API をサポートするすべてのモデルを使用できますが、すべてのパラメーターがサポートされているわけではありません。 Mistral-Large-3 model
AZURE_OPENAI_API_VERSION 使用する API バージョン。 api_versionが使用可能になったら、OpenAI クライアントを構築し、api-versionを使用して default_query クエリ パラメーターを挿入します。 v1 または preview api_version
ANTHROPIC_FOUNDRY_RESOURCE endpointとAzureAIAnthropicChatModelが設定されていない場合にproject_endpointによって使用される Foundry リソース名。 contoso endpoint

重要

AZURE_AI_INFERENCE_ENDPOINTまたはAZURE_AI_CREDENTIALS (レガシ) に使用AzureAIChatCompletionsModel環境変数とAzureAIEmbeddingsModelは使用されなくなりました。

次の手順