Azure OpenAI ↗ では、自然言語アルゴリズムをデータに適用できます。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/azure-openai/{resource_name}/{deployment_name}Azure OpenAI へリクエストするときは、次が必要です。
- AI Gateway のアカウント ID
- AI Gateway のゲートウェイ名
- Azure OpenAI の API キー
- Azure OpenAI のリソース名
- Azure OpenAI のデプロイ名(モデル名)
新しいベース URL は、上記の値を使って次の形式になります。https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/azure-openai/{resource_name}/{deployment_name}。そのあと、エンドポイントと api-version をベース URL の末尾に付けます。例: .../chat/completions?api-version=2023-05-15。
curl 'https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway}/azure-openai/{resource_name}/{deployment_name}/chat/completions?api-version=2023-05-15' \
--header 'Content-Type: application/json' \
--header 'api-key: {azure_api_key}' \
--data '{
"messages": [
{
"role": "user",
"content": "What is Cloudflare?"
}
]
}'import { AzureOpenAI } from "openai";
const azure_openai = new AzureOpenAI({
apiKey: "{azure_api_key}",
baseURL: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway}/azure-openai/{resource_name}/`,
apiVersion: "2023-05-15",
defaultHeaders: { "cf-aig-authorization": "{cf-api-token}" }, // if authenticated
});
const result = await azure_openai.chat.completions.create({
model: '{deployment_name}',
messages: [{ role: "user", content: "Hello" }],
});