次の方法で共有


OpenAIClient class

Azure OpenAI と対話するためのクライアント。

クライアントには、OpenAI リソースのエンドポイントと、API キーやトークンなどの認証方法が必要です。 API キーとエンドポイントは、OpenAI リソース ページにあります。 これらは、リソースの [キーとエンドポイント] ページにあります。

認証の例:

API キー

import { OpenAIClient } from "@azure/openai";
import { AzureKeyCredential } from "@azure/core-auth";

const endpoint = "<azure endpoint>";
const credential = new AzureKeyCredential("<api key>");

const client = new OpenAIClient(endpoint, credential);

Azure Active Directory

import { OpenAIClient } from "@azure/openai";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "<azure endpoint>";
const credential = new DefaultAzureCredential();

const client = new OpenAIClient(endpoint, credential);

コンストラクター

OpenAIClient(KeyCredential, OpenAIClientOptions)

Azure 以外の OpenAI エンドポイントで使用するために OpenAIClient のインスタンスを初期化します。

OpenAIClient(string, KeyCredential, OpenAIClientOptions)

Azure OpenAI リソースで使用するために OpenAIClient のインスタンスを初期化します。

OpenAIClient(string, TokenCredential, OpenAIClientOptions)

Azure OpenAI リソースで使用するために OpenAIClient のインスタンスを初期化します。

メソッド

getAudioTranscription(string, Uint8Array, GetAudioTranscriptionOptions)

オーディオ ファイルの文字起こしを単純な JSON 形式で返します。

getAudioTranscription<Format>(string, Uint8Array, Format, GetAudioTranscriptionOptions)

オーディオ ファイルの文字起こしを返します。

getAudioTranslation(string, Uint8Array, GetAudioTranslationOptions)

オーディオ ファイルの翻訳を返します。

getAudioTranslation<Format>(string, Uint8Array, Format, GetAudioTranslationOptions)

オーディオ ファイルの翻訳を返します。

getChatCompletions(string, ChatRequestMessageUnion[], GetChatCompletionsOptions)

指定されたチャット メッセージのチャット完了を取得します。 入力候補は、さまざまなタスクをサポートし、指定されたプロンプト データから継続または "完了" するテキストを生成します。

getCompletions(string, string[], GetCompletionsOptions)

指定された入力プロンプトの入力候補を取得します。 入力候補は、さまざまなタスクをサポートし、指定されたプロンプト データから継続または "完了" するテキストを生成します。

getEmbeddings(string, string[], GetEmbeddingsOptions)

指定されたプロンプトの埋め込みを返却します。

getImages(string, string, GetImagesOptions)

プロンプトが表示されたイメージを作成します。

streamChatCompletions(string, ChatRequestMessageUnion[], GetChatCompletionsOptions)

チャット コンテキストで使用できるようになると、チャット完了トークンをListsします。

streamCompletions(string, string[], GetCompletionsOptions)

入力候補トークンが特定のプロンプトで使用できるようになると、完了トークンをListsします。

コンストラクターの詳細

OpenAIClient(KeyCredential, OpenAIClientOptions)

Azure 以外の OpenAI エンドポイントで使用するために OpenAIClient のインスタンスを初期化します。

new OpenAIClient(openAiApiKey: KeyCredential, options?: OpenAIClientOptions)

パラメーター

openAiApiKey
KeyCredential

Azure OpenAI 以外のエンドポイントに接続するときに使用する API キー。

options
OpenAIClientOptions

クライアントを構成するためのオプション。

注釈

このコンストラクターで初期化された OpenAIClient オブジェクトは、Azure 以外の OpenAI 推論エンドポイントでのみ使用できます。 Azure OpenAI リソースで OpenAIClient を使用するには、代わりにリソース URI と Azure 認証資格情報を受け入れるコンストラクターを使用します。

OpenAIClient(string, KeyCredential, OpenAIClientOptions)

Azure OpenAI リソースで使用するために OpenAIClient のインスタンスを初期化します。

new OpenAIClient(endpoint: string, credential: KeyCredential, options?: OpenAIClientOptions)

パラメーター

endpoint

string

プロトコルとホスト名を含む Azure OpenAI リソースの URI。 (例: https://my-resource.openai.azure.com)。

credential
KeyCredential

Azure OpenAI リソースに対する認証に使用されるキー資格情報。

options
OpenAIClientOptions

クライアントを構成するためのオプション。

注釈

このコンストラクターは、Azure OpenAI リソースでのみ使用できる OpenAIClient オブジェクトを初期化します。 Azure OpenAI 以外の推論エンドポイントで OpenAIClient を使用するには、代わりに Azure 以外の OpenAI API キーを受け入れるコンストラクターを使用します。

OpenAIClient(string, TokenCredential, OpenAIClientOptions)

Azure OpenAI リソースで使用するために OpenAIClient のインスタンスを初期化します。

new OpenAIClient(endpoint: string, credential: TokenCredential, options?: OpenAIClientOptions)

パラメーター

endpoint

string

プロトコルとホスト名を含む Azure OpenAI リソースの URI。 (例: https://my-resource.openai.azure.com)。

credential
TokenCredential

Azure OpenAI リソースで認証するために使用されるトークン資格情報。

options
OpenAIClientOptions

クライアントを構成するためのオプション。

メソッドの詳細

getAudioTranscription(string, Uint8Array, GetAudioTranscriptionOptions)

オーディオ ファイルの文字起こしを単純な JSON 形式で返します。

function getAudioTranscription(deploymentName: string, fileContent: Uint8Array, options?: GetAudioTranscriptionOptions): Promise<AudioResultSimpleJson>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

fileContent

Uint8Array

文字起こしするオーディオ ファイルの内容。

options
GetAudioTranscriptionOptions

このオーディオ文字起こし要求のオプション。

戻り値

オーディオ文字起こしは単純な JSON 形式になります。

getAudioTranscription<Format>(string, Uint8Array, Format, GetAudioTranscriptionOptions)

オーディオ ファイルの文字起こしを返します。

function getAudioTranscription<Format>(deploymentName: string, fileContent: Uint8Array, format: Format, options?: GetAudioTranscriptionOptions): Promise<AudioResult<Format>>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

fileContent

Uint8Array

文字起こしするオーディオ ファイルの内容。

format

Format

結果オブジェクトの形式。 使用可能な値については、「 AudioResultFormat 」を参照してください。

options
GetAudioTranscriptionOptions

このオーディオ文字起こし要求のオプション。

戻り値

Promise<AudioResult<Format>>

オーディオ文字起こしは、任意の形式になります。

getAudioTranslation(string, Uint8Array, GetAudioTranslationOptions)

オーディオ ファイルの翻訳を返します。

function getAudioTranslation(deploymentName: string, fileContent: Uint8Array, options?: GetAudioTranslationOptions): Promise<AudioResultSimpleJson>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

fileContent

Uint8Array

翻訳するオーディオ ファイルの内容。

options
GetAudioTranslationOptions

このオーディオ翻訳要求のオプション。

戻り値

オーディオ翻訳の結果。

getAudioTranslation<Format>(string, Uint8Array, Format, GetAudioTranslationOptions)

オーディオ ファイルの翻訳を返します。

function getAudioTranslation<Format>(deploymentName: string, fileContent: Uint8Array, format: Format, options?: GetAudioTranslationOptions): Promise<AudioResult<Format>>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

fileContent

Uint8Array

翻訳するオーディオ ファイルの内容。

format

Format

結果オブジェクトの形式。 使用可能な値については、「 AudioResultFormat 」を参照してください。

options
GetAudioTranslationOptions

このオーディオ翻訳要求のオプション。

戻り値

Promise<AudioResult<Format>>

オーディオ翻訳の結果。

getChatCompletions(string, ChatRequestMessageUnion[], GetChatCompletionsOptions)

指定されたチャット メッセージのチャット完了を取得します。 入力候補は、さまざまなタスクをサポートし、指定されたプロンプト データから継続または "完了" するテキストを生成します。

function getChatCompletions(deploymentName: string, messages: ChatRequestMessageUnion[], options?: GetChatCompletionsOptions): Promise<ChatCompletions>

パラメーター

deploymentName

string

戻り値

Promise<ChatCompletions>

getCompletions(string, string[], GetCompletionsOptions)

指定された入力プロンプトの入力候補を取得します。 入力候補は、さまざまなタスクをサポートし、指定されたプロンプト データから継続または "完了" するテキストを生成します。

function getCompletions(deploymentName: string, prompt: string[], options?: GetCompletionsOptions): Promise<Completions>

パラメーター

deploymentName

string

prompt

string[]

戻り値

Promise<Completions>

getEmbeddings(string, string[], GetEmbeddingsOptions)

指定されたプロンプトの埋め込みを返却します。

function getEmbeddings(deploymentName: string, input: string[], options?: GetEmbeddingsOptions): Promise<Embeddings>

パラメーター

deploymentName

string

input

string[]

戻り値

Promise<Embeddings>

getImages(string, string, GetImagesOptions)

プロンプトが表示されたイメージを作成します。

function getImages(deploymentName: string, prompt: string, options?: GetImagesOptions): Promise<ImageGenerations>

パラメーター

deploymentName

string

prompt

string

戻り値

Promise<ImageGenerations>

streamChatCompletions(string, ChatRequestMessageUnion[], GetChatCompletionsOptions)

チャット コンテキストで使用できるようになると、チャット完了トークンをListsします。

function streamChatCompletions(deploymentName: string, messages: ChatRequestMessageUnion[], options?: GetChatCompletionsOptions): Promise<EventStream<ChatCompletions>>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

messages

ChatRequestMessageUnion[]

この要求に使用するチャット コンテキスト メッセージ。

options
GetChatCompletionsOptions

このチャット入力候補要求のチャット入力候補オプション。

戻り値

チャット完了トークンの非同期の iterable。

streamCompletions(string, string[], GetCompletionsOptions)

入力候補トークンが特定のプロンプトで使用できるようになると、完了トークンをListsします。

function streamCompletions(deploymentName: string, prompt: string[], options?: GetCompletionsOptions): Promise<EventStream<Omit<Completions, "usage">>>

パラメーター

deploymentName

string

この要求に使用するモデル デプロイの名前 (Azure OpenAI を使用する場合) またはモデル名 (Azure 以外の OpenAI を使用する場合)。

prompt

string[]

この要求に使用するプロンプト。

options
GetCompletionsOptions

この入力候補要求の入力候補オプション。

戻り値

Promise<EventStream<Omit<Completions, "usage">>>

完了トークンの非同期の iterable。