OpenAI エージェント

Important

2026年1月現在、AI Shellプロジェクトはもはや活発なメンテナンスは行われていません。 このプロジェクトは工学的観点からアーカイブされていると考えるべきです。

このエージェントは、OpenAI サービスと対話するためのユーザーフレンドリーなプラットフォームを提供します。 OpenAI エージェントは、パブリック OpenAI サービス、Azure OpenAI サービスのプライベート デプロイ、またはその他の OpenAI 互換サービスに接続できます。 セキュリティとプライバシーを強化するために、Azure OpenAI デプロイを使用することをお勧めします。

前提 条件

エージェントを使用する前に、エージェント構成ファイルで少なくとも 1 つの GPT インスタンスを構成する必要があります。 OpenAI の実装に関する次の情報を収集します。

  • ModelName - 使用する AI モデルの名前
  • Key - OpenAI サービスへのリクエストの認証に使用される API キー
  • Endpoint - Azure OpenAI およびその他のサードパーティ サービスに必要
  • Deployment - Azure OpenAI デプロイの名前

また、GPT インスタンスに NameDescriptionSystemPromptを指定する必要があります。

  • Name - エージェント構成で GPT インスタンスを識別します。
  • Description - その目的と機能に関する追加のコンテキストを提供します
  • SystemPrompt - GPT インスタンスの動作と性格を定義します。

これらの値は、ニーズに合わせてカスタマイズできます。

構成

GPT は、ベース OpenAI モデルのカスタマイズされたバージョンです。 GPT を使用して、モデルに指定したシステム プロンプトに基づいて、フォーカスされた応答を提供します。 システムプロンプトとモデルを変更することで、特定のドメインまたはシナリオに合わせて調整された複数のGPTを同じエンドポイントに対して作成できます。

  • Azure OpenAI には、 EndpointDeploymentModelNameKey または AuthType が必要です。
  • パブリックOpenAIは、 ModelNameKeyのみを必要とします。 エンドポイントはOpenAIによって修正されています。 デプロイ名はありません。
  • 他の OpenAI 互換サービスには、通常、 EndpointModelName、および Keyが必要です。

GPO は、エージェントの設定ファイルで構成されます。 デフォルトのエディターを使用して構成ファイルを開くには、 /agent config openai-gpt コマンドを使用します。

次の例に基づいてファイルを更新します。

{
  // Declare GPT instances.
  "GPTs": [
    // To use the Azure OpenAI service:
    // - Set `Endpoint` to the endpoint of your Azure OpenAI service,
    //   or the endpoint to the Azure API Management service if you are using it as a gateway.
    // - Set `Deployment` to the deployment name of your Azure OpenAI service.
    // - Set `ModelName` to the name of the model used for your deployment, e.g. "gpt-4-0613".
    // - Set `Key` to the access key of your Azure OpenAI service,
    //   or the key of the Azure API Management service if you are using it as a gateway.
    {
      "Name": "ps-az-gpt4",
      "Description": "A GPT instance with expertise in PowerShell scripting and command line utilities. Use gpt-4 running in Azure.",
      "Endpoint": "<insert your Azure OpenAI endpoint>",
      "Deployment": "<insert your deployment name>",
      "ModelName": "<insert the model name>",   // required field to infer properties of the service, such as token limit.
      "Key": "<insert your key>",
      "SystemPrompt": "1. You are a helpful and friendly assistant with expertise in PowerShell scripting and command line.\n2. Assume user is using the operating system `Windows 11` unless otherwise specified.\n3. Use the `code block` syntax in markdown to encapsulate any part in responses that is code, YAML, JSON or XML, but not table.\n4. When encapsulating command line code, use '```powershell' if it's PowerShell command; use '```sh' if it's non-PowerShell CLI command.\n5. When generating CLI commands, never ever break a command into multiple lines. Instead, always list all parameters and arguments of the command on the same line.\n6. Please keep the response concise but to the point. Do not overexplain."
    },

    // To use the public OpenAI service:
    // - Ignore the `Endpoint` and `Deployment` keys.
    // - Set `ModelName` to the name of the model to be used.
    // - Set `Key` to be the OpenAI access token.
    // For example:
    {
        "Name": "ps-gpt4o",
        "Description": "A GPT instance with expertise in PowerShell scripting and command line utilities. Use gpt-4o running in OpenAI.",
        "ModelName": "gpt-4o",
        "Key": "<insert your key>",
        "SystemPrompt": "1. You are a helpful and friendly assistant with expertise in PowerShell scripting and command line.\n2. Assume user is using the operating system `Windows 11` unless otherwise specified.\n3. Use the `code block` syntax in markdown to encapsulate any part in responses that is code, YAML, JSON or XML, but not table.\n4. When encapsulating command line code, use '```powershell' if it's PowerShell command; use '```sh' if it's non-PowerShell CLI command.\n5. When generating CLI commands, never ever break a command into multiple lines. Instead, always list all parameters and arguments of the command on the same line.\n6. Please keep the response concise but to the point. Do not overexplain."
    }
  ],

  // Specify the default GPT instance to use for user query.
  "Active": "ps-az-gpt4"
}

/gpt 命令

/gpt コマンドを使用して、使用する GPT を一覧表示して選択します。

  • /gpt use <gpt-name>を実行して別のGPTインスタンスに切り替えるか、/gpt useを実行して使用可能なものから選択します。
  • /gpt list <gpt-name> を実行して GPT 定義の詳細を表示するか、/gpt list 実行して使用可能なすべての GPT を一覧表示します。

Microsoft Entra ID 認証のサポート

OpenAI エージェントは、Azure OpenAI インスタンスの Entra ID 認証をサポートします。 キーを指定する代わりに、 AuthType プロパティを EntraID に設定します。 これにより、エージェントは構成ファイルにキーを格納せずに Azure OpenAI リソースにアクセスできます。

{
  // Declare GPT instances.
  "GPTs": [
      // Declaration of an Azure OpenAI instance with EntraID authentication
      {
        "Name": "ps-az-entraId",
        "Description": "A GPT instance with expertise in PowerShell scripting using Entra ID authentication.",
        "Endpoint": "<Your Endpoint>",
        "Deployment": "<Your Deployment Name>",
        "ModelName": "<Your Model Name>",
        "AuthType": "EntraID",
        "SystemPrompt": "You are a helpful and friendly assistant with expertise in PowerShell scripting and command line."
      }
  ],

  // Specify the default GPT instance to use for user query.
  "Active": "ps-az-entraId"
}

Azure OpenAI では、認証に次の資格情報の階層が使用されます。

  • EnvironmentCredential
  • WorkloadIdentityCredential
  • ManagedIdentityCredential
  • SharedTokenCacheCredential
  • VisualStudioCredential
  • AzureCliCredential
  • AzurePowerShellCredential
  • AzureDeveloperCliCredential
  • InteractiveBrowserCredential

これらの資格情報の詳細については、 DefaultAzureCredential の .NET ドキュメントを参照してください。

その他のOpenAI互換モデルのサポート

OpenAI エージェントは、OpenAI API 仕様を実装するサードパーティの AI サービスをサポートしています。 これらのモデルの一部は、SLM と LLM をローカルで実行するためのオープンソース ツールです。 OpenAI エージェントは、次のサードパーティ モデルをサポートしています。

Foundry Local は、Microsoft のオンデバイス AI 推論ソリューションで、現在パブリック プレビュー中です。 AI Shell は、OpenAI エージェントを使用してそれとインターフェイスします。 AI Shellで使用する前に、マシンにFoundry Localをインストールして設定する必要があります。 詳細については、「 Foundry Local の使用を開始する」を参照してください。

OpenAI エージェントは、次のモデル名をサポートしています。

  • o1
  • o3
  • o4-mini
  • gpt-5
  • gpt-4.1
  • gpt-4o
  • gpt-4
  • gpt-4-32k
  • gpt-4-turbo
  • gpt-3.5-turbo
  • gpt-35-turbo - モデルの Azure OpenAI 名
  • Foundry Local でサポートされているモデル ID

エンドポイントとモデル名の詳細については、使用する AI サービスのサードパーティ ドキュメントを参照してください。

Foundry ローカルエンドポイントの構成

Foundry Local をインストールしたら、次のコマンドを実行して、OpenAI エージェントの設定に必要な情報を取得します。

PS> foundry service start
🟢 Service is already running on http://127.0.0.1:56952/.

PS> foundry model load phi-3.5-mini
🕔 Loading model...
🟢 Model phi-3.5-mini loaded successfully

PS> foundry service ps
Models running in service:
    Alias                          Model ID
🟢  phi-3.5-mini                   Phi-3.5-mini-instruct-generic-cpu

この例では、Foundry Local サービスを開始し、 phi-3.5-mini モデルをロードし、サービスで実行中のモデルを一覧表示します。

次に、新しいGPTを openai.agent.json ファイルに追加します。

  • foundry service startには、サービスの URI が表示されます。 OpenAI エージェントの Endpoint は、URI と /v1 です。
  • foundry service psコマンドは、ModelNameとしてを表示します。 モデル ID に示されている正確な大文字と小文字を使用するようにしてください。 Foundry Local では大文字と小文字が区別されます。
  • API キーは OPENAI_API_KEYするようにハードコードされています。
{
  "GPTs": [
    {
      "Name": "foundry-local",
      "Description": "A GPT instance using Foundry Local.",
      "Endpoint": "http://127.0.0.1:56952/v1",
      "ModelName": "Phi-3.5-mini-instruct-generic-cpu",
      "Key": "OPENAI_API_KEY"
    }
  ]

  "Active": "foundry-local"
}