Microsoft Foundry 模型中的 Azure OpenAI REST API 參照

本文提供 Azure OpenAI 推論 REST API 端點的詳細資訊。

API specs

管理與互動 Azure OpenAI 模型與資源分為三大主要 API 介面:

  • Control plane
  • 資料平面 - 著述
  • 資料平面 - 推論

每個 API 表面/規範都封裝了一組不同的 Azure OpenAI 功能。 每個 API 都有其獨特的預覽版及穩定/一般可用(GA)API 版本。 預覽版目前通常以每月更新為準。

Important

現在有一個新的預覽推論 API。 想了解更多,請參閱我們的 API 生命週期指南

API 最新預覽發布 最新 GA 發行 Specifications Description
Control plane 2025-07-01-preview 2025-06-01 Spec files 控制平面 API 用於 建立資源模型部署及其他高階資源管理任務等操作。 控制平面也管理像 Azure Resource Manager、Bicep、Terraform 和 Azure CLI 這類功能能做什麼。
Data plane v1 preview v1 Spec files 資料平面 API 控制推理與撰寫操作。

Authentication

Azure OpenAI 提供兩種認證方法。 你可以使用 API Keys 或 Microsoft Entra ID。

  • API 金鑰認證:此類型驗證中,所有 API 請求必須在 api-key HTTP 標頭中包含 API 金鑰。 快速入門指南提供了如何使用此類認證打電話的指引。

  • Microsoft Entra ID authentication:你可以用 Microsoft Entra tokens 來驗證 API 呼叫。 認證憑證作為標頭包含在請求 Authorization 中。 所提供的標記必須前置 Bearer,例如 Bearer YOUR_AUTH_TOKEN。 你可以閱讀我們關於使用 Microsoft Entra ID 認證的操作指南。

REST API 版本管理

服務 API 會透過 api-version 查詢參數來進行版本控制。 所有版本皆遵循 YYYY -MM-DD 日期結構。 For example:

POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2024-06-01

資料平面推論

文章其餘部分涵蓋 Azure OpenAI 資料平面推論規範 2024-10-21 的 GA 版本。

如果你在尋找最新預覽 API 版本的文件,請參考 最新的預覽資料平面推論 API

Completions

POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-10-21

為所提供的提示詞、參數及所選模型建立補全。

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串 已部署型號的部署ID。
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: application/json

Name 類型 Description Required Default
提示 字串或陣列 生成補全的提示,編碼為字串、字串陣列、標記陣列或標記陣列。

請注意, <|endoftext|> 是模型在訓練時看到的文件分隔符,因此如果未指定提示詞,模型會像從新文件開始一樣產生。
Yes
best_of 整數 best_of 伺服器端產生完成項目,並回傳「最佳」(每個標記日誌機率最高的完成)。 結果無法直播。

當與 一起使用 n時, best_of 控制候選完成數,並 n 指定要回傳的數量—— best_of 必須大於 n

註: 由於這個參數會產生許多完成任務,它可能會迅速消耗你的代幣配額。 謹慎使用,並確保你對 和 max_tokens的設定stop合理。
No 1
echo boolean 除了完成題外,還要回敬提示
No False
frequency_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新標記在文本中現有的頻率來懲罰,降低模型逐字重複同一行的可能性。
No 0
logit_bias 物件 修改特定標記出現在完成項目中的可能性。

接受一個 JSON 物件,將 GPT 分名器中由 token ID 指定)映射到從 -100 到 100 的偏值。 數學上,偏差會加到模型產生的對數值上,然後再進行抽樣。 具體效果會因模型而異,但介於 -1 與1之間的數值應降低或增加被選中的機率;像 -100 或 100 這類數值應該會導致封鎖或專屬選擇相關代幣。

舉例來說,你可以通過, {"50256": -100} 以防止 <|endoftext|> 標記被產生。
No None
logprobs 整數 包含最可能輸出標記的對數機率 logprobs ,以及所選標記。 例如,若 logprobs 為 5,API 會回傳五個最可能的標記清單。 API 會回傳取樣標記的 , logprob 因此回應中可能包含最多的 logprobs+1 元素。

最大 logprobs 值為5。
No None
max_tokens 整數 完成過程中可產生的最大代幣數量。

你的提示 max_tokens 詞的標記數不能超過模型的上下文長度。
No 16
n 整數 每個提示要產生多少個完成題。

註: 由於這個參數會產生許多完成任務,它可能會迅速消耗你的代幣配額。 謹慎使用,並確保你對 和 max_tokens的設定stop合理。
No 1
presence_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新代幣是否出現在文本中來懲罰,增加模型談論新主題的可能性。
No 0
seed 整數 若有指定,系統會盡力以確定性方式取樣,使得重複請求與參數相同 seed 時應返回相同結果。

確定性並非保證,你應該參考 system_fingerprint 回應參數來監控後端的變化。
No
stop 字串或陣列 最多有四個序列,API 會停止產生更多代幣。 回傳的文字不會包含停止音序列。
No
串流 boolean 是否要回溯部分進度。 若設定為此,代幣將以僅資料伺服器 發送的事件 形式在有可用時傳送,串流會以訊息終止 data: [DONE] No False
suffix 字串 插入文字完成後的後綴。

此參數僅支援於 gpt-3.5-turbo-instruct
No None
temperature number 取樣溫度該用什麼?介於0到2之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。

我們通常建議改變這個或 top_p 兩者都做。
No 1
top_p number 另一種以溫度抽樣為基礎的替代方案稱為核抽樣,模型考慮以top_p機率質量計算的符號結果。 因此 0.1 表示只考慮包含前 10 個% 機率質量的代幣。

我們通常建議改變這個或 temperature 兩者都做。
No 1
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。
No

Responses

狀態代碼: 200

Description: OK

Content-Type Type Description
application/json createCompletionResponse 代表 API 的補全回應。 注意:串流與非串流回應物件的形狀相同(與聊天端點不同)。

狀態代碼: 預設

說明:無法提供服務

Content-Type Type Description
application/json errorResponse

Examples

Example

為所提供的提示詞、參數及所選模型建立補全。

POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-10-21

{
 "prompt": [
  "tell me a joke about mango"
 ],
 "max_tokens": 32,
 "temperature": 1.0,
 "n": 1
}

回應:狀態代碼:200

{
  "body": {
    "id": "cmpl-7QmVI15qgYVllxK0FtxVGG6ywfzaq",
    "created": 1686617332,
    "choices": [
      {
        "text": "es\n\nWhat do you call a mango who's in charge?\n\nThe head mango.",
        "index": 0,
        "finish_reason": "stop",
        "logprobs": null
      }
    ],
    "usage": {
      "completion_tokens": 20,
      "prompt_tokens": 6,
      "total_tokens": 26
    }
  }
}

Embeddings

POST https://{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version=2024-10-21

取得一個能被機器學習模型和演算法輕鬆處理的給定輸入向量表示。

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: application/json

Name 類型 Description Required Default
輸入 字串或陣列 輸入文字嵌入,編碼為字串或標記陣列。 若要在同一請求中嵌入多個輸入,需傳遞一個字串陣列或標記陣列陣列。 輸入不得超過模型的最大輸入標記數(8,192個標記 text-embedding-ada-002),不能是空字串,且任何陣列的維度必須不超過2,048維或以下。 Yes
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控與偵測濫用行為。 No
input_type 字串 輸入類型的嵌入搜尋 No
encoding_format 字串 格式是要將嵌入還回。 可以是 floatbase64。 預設為 float No
dimensions 整數 輸出嵌入應有的維度數。 僅支援於 text-embedding-3 及後期型號。 No

Responses

Name 類型 Description Required Default
物件 字串 Yes
型號 字串 Yes
資料 陣列 Yes
使用方式 物件 Yes

用途特性

prompt_tokens

Name 類型 Description Default
prompt_tokens 整數

total_tokens

Name 類型 Description Default
total_tokens 整數

狀態代碼: 200

Description: OK

Content-Type Type Description
application/json 物件

Examples

Example

回傳給定提示的嵌入。

POST https://{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version=2024-10-21

{
 "input": [
  "this is a test"
 ]
}

回應:狀態代碼:200

{
  "body": {
    "data": [
      {
        "index": 0,
        "embedding": [
          -0.012838088,
          -0.007421397,
          -0.017617522,
          -0.028278312,
          -0.018666342,
          0.01737855,
          -0.01821495,
          -0.006950092,
          -0.009937238,
          -0.038580645,
          0.010674067,
          0.02412286,
          -0.013647936,
          0.013189907,
          0.0021125758,
          0.012406612,
          0.020790534,
          0.00074595667,
          0.008397198,
          -0.00535031,
          0.008968075,
          0.014351576,
          -0.014086051,
          0.015055214,
          -0.022211088,
          -0.025198232,
          0.0065186154,
          -0.036350243,
          0.009180495,
          -0.009698266,
          0.009446018,
          -0.008463579,
          -0.0040426035,
          -0.03443847,
          -0.00091273896,
          -0.0019217303,
          0.002349888,
          -0.021560553,
          0.016515596,
          -0.015572986,
          0.0038666942,
          -8.432463e-05
        ]
      }
    ],
    "usage": {
      "prompt_tokens": 4,
      "total_tokens": 4
    }
  }
}

Chat completions

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

為聊天訊息建立一個完成

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串 已部署型號的部署ID。
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: application/json

Name 類型 Description Required Default
temperature number 取樣溫度該用什麼?介於0到2之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。

我們通常建議改變這個或 top_p 兩者都做。
No 1
top_p number 另一種以溫度抽樣為基礎的替代方案稱為核抽樣,模型考慮以top_p機率質量計算的符號結果。 因此 0.1 表示只考慮包含前 10 個% 機率質量的代幣。

我們通常建議改變這個或 temperature 兩者都做。
No 1
串流 boolean 若設定為此,會傳送部分訊息 delta,類似 ChatGPT 中的訊息。 代幣將以僅資料伺服器 發送的事件 形式在有空時發送,串流會 data: [DONE] 以訊息終止。 No False
stop 字串或陣列 最多有四個序列,API 會停止產生更多代幣。
No
max_tokens 整數 聊天完成時能產生的最大代幣數量。

輸入標記與產生標記的總長度受模型上下文長度限制。
No
max_completion_tokens 整數 完成化可產生的標記數量上限,包括可見輸出標記與推理標記。 No
presence_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新代幣是否出現在文本中來懲罰,增加模型談論新主題的可能性。
No 0
frequency_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新標記在文本中現有的頻率來懲罰,降低模型逐字重複同一行的可能性。
No 0
logit_bias 物件 修改特定標記出現在完成項目中的可能性。

接受一個 JSON 物件,將代幣(由代幣化器中由其 token ID 指定)映射到從 -100 到 100 的偏向值。 數學上,偏差會加到模型產生的對數值上,然後再進行抽樣。 具體效果會因模型而異,但介於 -1 與1之間的數值應降低或增加被選中的機率;像 -100 或 100 這類數值應該會導致封鎖或專屬選擇相關代幣。
No None
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。
No
messages 陣列 這是目前對話內容的清單。 Yes
data_sources 陣列 Azure OpenAI 聊天擴充功能的設定項目。
此額外規範僅與 Azure OpenAI 相容。
No
logprobs boolean 是否要回傳輸出標記的對數機率。 若為真,則回傳每個輸出符號在 contentmessage對數機率。 No False
top_logprobs 整數 一個介於0到20之間的整數,表示每個標記位置最可能回傳的標記數量,每個標記具有對數機率。 logprobs 若使用此參數,必須設定為 true No
n 整數 每則輸入訊息要產生多少個聊天結束選項。 請注意,你將根據所有選項中產生的代幣數量收費。 盡量降低n1成本。 No 1
parallel_tool_calls ParallelToolCalls 是否在工具使用時啟用平行函式呼叫。 No True
response_format ResponseFormatTextResponseFormatJsonObjectResponseFormatJsonSchema 一個指定模型必須輸出格式的物件。 相容於 GPT-4oGPT-4o miniGPT-4 Turbo 以及所有更新於 Tar 的 gpt-3.5-turbo-1106 Turbo 模型。

設定為 { "type": "json_schema", "json_schema": {...} } 啟用結構化輸出,保證模型會符合你提供的 JSON 架構。

設定啟用 { "type": "json_object" } JSON 模式,保證模型產生的訊息是有效的 JSON。

重要提示: 使用 JSON 模式時, 你也必須 指示模型透過系統或使用者訊息自行產生 JSON。 若無此,模型可能會產生無盡的空白流,直到產生達到代幣上限,導致請求長時間且看似「卡住」。 另外請注意,若 finish_reason="length",訊息內容可能會部分中斷,表示產生 max_tokens 次數或對話超過最大上下文長度。
No
seed 整數 此功能目前仍處於測試階段。
若有指定,系統會盡力以確定性方式取樣,使得重複請求與參數相同 seed 時應返回相同結果。
確定性並非保證,你應該參考 system_fingerprint 回應參數來監控後端的變化。
No
tools 陣列 模型可能呼叫的工具清單。 目前僅支援函式作為工具。 利用此資料提供模型可能產生 JSON 輸入的函式清單。 最多支援 128 個函式。
No
tool_choice chatCompletionToolChoiceOption 控制模型呼叫哪個(如果有)工具。 none 這表示模型不會呼叫任何工具,而是產生訊息。 auto 表示模型可以選擇產生訊息或呼叫一個或多個工具。 required 表示模型必須呼叫一個或多個工具。 指定特定工具 透過 會 {"type": "function", "function": {"name": "my_function"}} 強制模型呼叫該工具。 none 當沒有工具時,預設是。 auto 如果有工具,則是預設。 No
function_call string 或 chatCompletionFunctionCallOption 已被棄用,改為 tool_choice

控制模型呼叫哪個函式(若有的話)。
none 表示模型不會呼叫函式,而是產生訊息。
auto 表示模型可以選擇產生訊息或呼叫函式。
指定特定函數 會 {"name": "my_function"} 迫使模型呼叫該函數。

none 當沒有函式存在時,是預設值。 auto 若函式存在,則為預設值。
No
functions 陣列 已被棄用,改為 tools

模型可能產生 JSON 輸入的函數清單。
No

Responses

狀態代碼: 200

Description: OK

Content-Type Type Description
application/json createChatCompletionResponsecreateChatCompletionStreamResponse

狀態代碼: 預設

說明:無法提供服務

Content-Type Type Description
application/json errorResponse

Examples

Example

為所提供的提示詞、參數及所選模型建立補全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

{
 "messages": [
  {
   "role": "system",
   "content": "you are a helpful assistant that talks like a pirate"
  },
  {
   "role": "user",
   "content": "can you tell me how to care for a parrot?"
  }
 ]
}

回應:狀態代碼:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Ahoy matey! So ye be wantin' to care for a fine squawkin' parrot, eh? Well, shiver me timbers, let ol' Cap'n Assistant share some wisdom with ye! Here be the steps to keepin' yer parrot happy 'n healthy:\n\n1. Secure a sturdy cage: Yer parrot be needin' a comfortable place to lay anchor! Be sure ye get a sturdy cage, at least double the size of the bird's wingspan, with enough space to spread their wings, yarrrr!\n\n2. Perches 'n toys: Aye, parrots need perches of different sizes, shapes, 'n textures to keep their feet healthy. Also, a few toys be helpin' to keep them entertained 'n their minds stimulated, arrrh!\n\n3. Proper grub: Feed yer feathered friend a balanced diet of high-quality pellets, fruits, 'n veggies to keep 'em strong 'n healthy. Give 'em fresh water every day, or ye\u00e2\u20ac\u2122ll have a scurvy bird on yer hands!\n\n4. Cleanliness: Swab their cage deck! Clean their cage on a regular basis: fresh water 'n food daily, the floor every couple of days, 'n a thorough scrubbing ev'ry few weeks, so the bird be livin' in a tidy haven, arrhh!\n\n5. Socialize 'n train: Parrots be a sociable lot, arrr! Exercise 'n interact with 'em daily to create a bond 'n maintain their mental 'n physical health. Train 'em with positive reinforcement, treat 'em kindly, yarrr!\n\n6. Proper rest: Yer parrot be needin' \u00e2\u20ac\u2122bout 10-12 hours o' sleep each night. Cover their cage 'n let them slumber in a dim, quiet quarter for a proper night's rest, ye scallywag!\n\n7. Keep a weather eye open for illness: Birds be hidin' their ailments, arrr! Be watchful for signs of sickness, such as lethargy, loss of appetite, puffin' up, or change in droppings, and make haste to a vet if need be.\n\n8. Provide fresh air 'n avoid toxins: Parrots be sensitive to draft and pollutants. Keep yer quarters well ventilated, but no drafts, arrr! Be mindful of toxins like Teflon fumes, candles, or air fresheners.\n\nSo there ye have it, me hearty! With proper care 'n commitment, yer parrot will be squawkin' \"Yo-ho-ho\" for many years to come! Good luck, sailor, and may the wind be at yer back!"
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

根據 Azure 搜尋資料和系統指派的管理身份建立一個完成文件。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_search",
   "parameters": {
    "endpoint": "https://your-search-endpoint.search.windows.net/",
    "index_name": "{index name}",
    "authentication": {
     "type": "system_assigned_managed_identity"
    }
   }
  }
 ]
}

回應:狀態代碼:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

根據 Azure 搜尋向量資料、先前的助理訊息及使用者指派的管理身份建立完成資料。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a cat?"
  },
  {
   "role": "assistant",
   "content": "Content of the completion [doc1].",
   "context": {
    "intent": "cat care"
   }
  },
  {
   "role": "user",
   "content": "how about dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_search",
   "parameters": {
    "endpoint": "https://your-search-endpoint.search.windows.net/",
    "authentication": {
     "type": "user_assigned_managed_identity",
     "managed_identity_resource_id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resource-name}"
    },
    "index_name": "{index name}",
    "query_type": "vector",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "in_scope": true,
    "top_n_documents": 5,
    "strictness": 3,
    "role_information": "You are an AI assistant that helps people find information.",
    "fields_mapping": {
     "content_fields_separator": "\\n",
     "content_fields": [
      "content"
     ],
     "filepath_field": "filepath",
     "title_field": "title",
     "url_field": "url",
     "vector_fields": [
      "contentvector"
     ]
    }
   }
  }
 ]
}

回應:狀態代碼:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content 2.",
                "title": "Citation Title 2",
                "filepath": "contoso2.txt",
                "url": "https://contoso.blob.windows.net/container/contoso2.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

為所提供的 Azure Cosmos DB 建立一個補全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-10-21

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_cosmos_db",
   "parameters": {
    "authentication": {
     "type": "connection_string",
     "connection_string": "mongodb+srv://rawantest:{password}$@{cluster-name}.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000"
    },
    "database_name": "vectordb",
    "container_name": "azuredocs",
    "index_name": "azuredocindex",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "fields_mapping": {
     "content_fields": [
      "content"
     ],
     "vector_fields": [
      "contentvector"
     ]
    }
   }
  }
 ]
}

回應:狀態代碼:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

轉錄 - 建立

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2024-10-21

將音訊轉錄成輸入語言。

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串 語音轉文字模型的部署ID。

有關支援模型的資訊,請參見 [/azure/ai-foundry/openai/concepts/models#audio-models]。
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: multipart/form-data

Name 類型 Description Required Default
檔案 字串 要轉錄的音訊檔案物件。 Yes
提示 字串 可選文字用來引導模型風格或延續先前的音訊片段。 提示詞應該與音頻語言相符。 No
response_format audioResponseFormat 定義輸出格式。 No
temperature number 取樣溫度介於0到1之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。 若設為 0,模型會利用對數機率自動升溫,直到達到特定閾值。 No 0
語言 字串 輸入音訊的語言。 以 ISO-639-1 格式提供輸入語言將提升準確度與延遲。 No

Responses

狀態代碼: 200

Description: OK

Content-Type Type Description
application/json audioResponseaudioVerboseResponse
text/plain 字串 以輸出格式轉錄文字(當response_format為文字、vtt 或 srt 時)。

Examples

Example

從提供的語音資料中取得文字轉錄及相關元資料。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2024-10-21

回應:狀態代碼:200

{
  "body": {
    "text": "A structured object when requesting json or verbose_json"
  }
}

Example

從提供的語音資料中取得文字轉錄及相關元資料。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2024-10-21

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回應:狀態代碼:200

{
  "type": "string",
  "example": "plain text when requesting text, srt, or vtt"
}

翻譯 - 創作

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2024-10-21

將輸入音訊轉錄並翻譯成英文文字。

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串 已部署的 whisper 模型的部署 ID。

有關支援模型的資訊,請參見 [/azure/ai-foundry/openai/concepts/models#audio-models]。
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: multipart/form-data

Name 類型 Description Required Default
檔案 字串 要翻譯的音訊檔案。 Yes
提示 字串 可選文字用來引導模型風格或延續先前的音訊片段。 題目應該是英文。 No
response_format audioResponseFormat 定義輸出格式。 No
temperature number 取樣溫度介於0到1之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。 若設為 0,模型會利用對數機率自動升溫,直到達到特定閾值。 No 0

Responses

狀態代碼: 200

Description: OK

Content-Type Type Description
application/json audioResponseaudioVerboseResponse
text/plain 字串 以輸出格式轉錄文字(當response_format為文字、vtt 或 srt 時)。

Examples

Example

從提供的語音資料中取得英文轉錄文字及相關元資料。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2024-10-21

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回應:狀態代碼:200

{
  "body": {
    "text": "A structured object when requesting json or verbose_json"
  }
}

Example

從提供的語音資料中取得英文轉錄文字及相關元資料。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2024-10-21

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回應:狀態代碼:200

{
  "type": "string",
  "example": "plain text when requesting text, srt, or vtt"
}

Image generation

POST https://{endpoint}/openai/deployments/{deployment-id}/images/generations?api-version=2024-10-21

在特定 dall-e 模型部署時,從文字說明產生一批圖片

URI Parameters

Name In Required 類型 Description
端點 路徑 Yes 字串
url
支援Azure OpenAI 端點(協定與主機名稱,例如:https://aoairesource.openai.azure.com。請將「aoairesource」替換成你的 Azure OpenAI 資源名稱)。 https://{your-resource-name}.openai.azure.com
deployment-id 路徑 Yes 字串 已部署的 dall-e 型號部署 ID。
api-version 查詢 Yes 字串 API version

Request Header

Name Required 類型 Description
api-key True 字串 在此輸入 Azure OpenAI API 金鑰

Request Body

Content-Type: application/json

Name 類型 Description Required Default
提示 字串 這是想要圖片的文字描述。 最大長度為4,000字元。 Yes
n 整數 要產生的影像數量。 No 1
size imageSize 產生的影像大小。 No 1024x1024
response_format imagesResponseFormat 產生影像回傳的格式。 No url
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。 No
quality imageQuality 所產生的影像品質。 No 標準
樣式 imageStyle 產生的圖片風格。 No vivid

Responses

狀態代碼: 200

Description: Ok

Content-Type Type Description
application/json generateImagesResponse

狀態代碼: 預設

說明:發生錯誤。

Content-Type Type Description
application/json dalleErrorResponse

Examples

Example

在提示下創作圖片。

POST https://{endpoint}/openai/deployments/{deployment-id}/images/generations?api-version=2024-10-21

{
 "prompt": "In the style of WordArt, Microsoft Clippy wearing a cowboy hat.",
 "n": 1,
 "style": "natural",
 "quality": "standard"
}

回應:狀態代碼:200

{
  "body": {
    "created": 1698342300,
    "data": [
      {
        "revised_prompt": "A vivid, natural representation of Microsoft Clippy wearing a cowboy hat.",
        "prompt_filter_results": {
          "sexual": {
            "severity": "safe",
            "filtered": false
          },
          "violence": {
            "severity": "safe",
            "filtered": false
          },
          "hate": {
            "severity": "safe",
            "filtered": false
          },
          "self_harm": {
            "severity": "safe",
            "filtered": false
          },
          "profanity": {
            "detected": false,
            "filtered": false
          }
        },
        "url": "https://dalletipusw2.blob.core.windows.net/private/images/e5451cc6-b1ad-4747-bd46-b89a3a3b8bc3/generated_00.png?se=2023-10-27T17%3A45%3A09Z&...",
        "content_filter_results": {
          "sexual": {
            "severity": "safe",
            "filtered": false
          },
          "violence": {
            "severity": "safe",
            "filtered": false
          },
          "hate": {
            "severity": "safe",
            "filtered": false
          },
          "self_harm": {
            "severity": "safe",
            "filtered": false
          }
        }
      }
    ]
  }
}

Components

errorResponse

Name 類型 Description Required Default
錯誤 error No

errorBase

Name 類型 Description Required Default
字碼 字串 No
訊息 字串 No

錯誤

Name 類型 Description Required Default
param 字串 No
型別 字串 No
inner_error innerError 內部錯誤加上額外細節。 No

innerError

內部錯誤加上額外細節。

Name 類型 Description Required Default
字碼 innerErrorCode 內部錯誤物件的錯誤代碼。 No
content_filter_results contentFilterPromptResults 關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。 No

innerErrorCode

內部錯誤物件的錯誤代碼。

說明:內部錯誤物件的錯誤代碼。

Type: string

Default:

列舉名稱:InnerErrorCode

Enum Values:

Value Description
ResponsibleAIPolicyViolation 這個提示違反了其中一條內容過濾規則。

dalleErrorResponse

Name 類型 Description Required Default
錯誤 dalleError No

dalleError

Name 類型 Description Required Default
param 字串 No
型別 字串 No
inner_error dalleInnerError 內部錯誤加上額外細節。 No

dalleInnerError

內部錯誤加上額外細節。

Name 類型 Description Required Default
字碼 innerErrorCode 內部錯誤物件的錯誤代碼。 No
content_filter_results dalleFilterResults 關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。 No
revised_prompt 字串 如果提示有任何修改,就是用來產生圖片的提示。 No

contentFilterResultBase

Name 類型 Description Required Default
filtered boolean Yes

contentFilterSeverityResult

Name 類型 Description Required Default
filtered boolean Yes
severity 字串 No

contentFilterDetectedResult

Name 類型 Description Required Default
filtered boolean Yes
detected boolean No

contentFilterDetectedWithCitationResult

Name 類型 Description Required Default
citation 物件 No

引用特性

URL

Name 類型 Description Default
URL 字串

使用權

Name 類型 Description Default
使用權 字串

contentFilterResultsBase

關於內容過濾結果的資訊。

Name 類型 Description Required Default
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No
profanity contentFilterDetectedResult No
錯誤 errorBase No

contentFilterPromptResults

關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。

Name 類型 Description Required Default
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No
profanity contentFilterDetectedResult No
錯誤 errorBase No
jailbreak contentFilterDetectedResult No

contentFilterChoiceResults

關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於第三方簡訊和髒話的資訊,是否已被偵測到,以及是否被過濾過。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。

Name 類型 Description Required Default
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No
profanity contentFilterDetectedResult No
錯誤 errorBase No
protected_material_text contentFilterDetectedResult No
protected_material_code contentFilterDetectedWithCitationResult No

promptFilterResult

請求中單一提示的內容過濾結果。

Name 類型 Description Required Default
prompt_index 整數 No
content_filter_results contentFilterPromptResults 關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。 No

promptFilterResults

針對請求中零或多個提示的內容篩選結果。 在串流請求中,不同提示的結果可能在不同時間或順序出現。

此元件未定義屬性。

dalleContentFilterResults

關於內容過濾結果的資訊。

Name 類型 Description Required Default
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No

dalleFilterResults

關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。

Name 類型 Description Required Default
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No
profanity contentFilterDetectedResult No
jailbreak contentFilterDetectedResult No

chatCompletionsRequestCommon

Name 類型 Description Required Default
temperature number 取樣溫度該用什麼?介於0到2之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。
我們通常建議改變這個或 top_p 兩者都做。
No 1
top_p number 另一種以溫度抽樣為基礎的替代方案稱為核抽樣,模型考慮以top_p機率質量計算的符號結果。 因此 0.1 表示只考慮包含前 10 個% 機率質量的代幣。
我們通常建議改變這個或 temperature 兩者都做。
No 1
串流 boolean 若設定為此,會傳送部分訊息 delta,類似 ChatGPT 中的訊息。 代幣將以僅資料伺服器發送的事件形式在有空時發送,串流會 data: [DONE] 以訊息終止。 No False
stop 字串或陣列 最多有四個序列,API 會停止產生更多代幣。 No
max_tokens 整數 產生答案允許的最大代幣數。 預設情況下,模型可返回的標記數量為(4096 - 提示標記)。 此值現已被棄用,改為 max_completion_tokens,且不相容於 o1 系列模型。 No 4096
max_completion_tokens 整數 完成化可產生的標記數量上限,包括可見輸出標記與推理標記。 No
presence_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新代幣是否出現在文本中來懲罰,增加模型談論新主題的可能性。 No 0
frequency_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新標記在文本中現有的頻率來懲罰,降低模型逐字重複同一行的可能性。 No 0
logit_bias 物件 修改特定標記出現在完成項目中的可能性。 接受一個 json 物件,將標記器中由標記 ID 指定的標記映射到從 -100 到 100 的偏向值。 數學上,偏差會加到模型產生的對數值上,然後再進行抽樣。 具體效果會因模型而異,但介於 -1 與1之間的數值應降低或增加被選中的機率;像 -100 或 100 這類數值應該會導致封鎖或專屬選擇相關代幣。 No
使用者 字串 一個代表終端使用者的獨特識別碼,能幫助 Azure OpenAI 監控並偵測濫用行為。 No

createCompletionRequest

Name 類型 Description Required Default
提示 字串或陣列 生成補全的提示,編碼為字串、字串陣列、標記陣列或標記陣列。

請注意, <|endoftext|> 是模型在訓練時看到的文件分隔符,因此如果未指定提示詞,模型會像從新文件開始一樣產生。
Yes
best_of 整數 best_of 伺服器端產生完成項目,並回傳「最佳」(每個標記日誌機率最高的完成)。 結果無法直播。

當與 一起使用 n時, best_of 控制候選完成數,並 n 指定要回傳的數量—— best_of 必須大於 n

註: 由於這個參數會產生許多完成任務,它可能會迅速消耗你的代幣配額。 謹慎使用,並確保你對 和 max_tokens的設定stop合理。
No 1
echo boolean 除了完成題外,還要回敬提示
No False
frequency_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新標記在文本中現有的頻率來懲罰,降低模型逐字重複同一行的可能性。
No 0
logit_bias 物件 修改特定標記出現在完成項目中的可能性。

接受一個 JSON 物件,將 GPT 分名器中由 token ID 指定)映射到從 -100 到 100 的偏值。 數學上,偏差會加到模型產生的對數值上,然後再進行抽樣。 具體效果會因模型而異,但介於 -1 與1之間的數值應降低或增加被選中的機率;像 -100 或 100 這類數值應該會導致封鎖或專屬選擇相關代幣。

舉例來說,你可以通過, {"50256": -100} 以防止 <|endoftext|> 標記被產生。
No None
logprobs 整數 包含最可能輸出標記的對數機率 logprobs ,以及所選標記。 例如,若 logprobs 為 5,API 會回傳五個最可能的標記清單。 API 會回傳取樣標記的 , logprob 因此回應中可能包含最多的 logprobs+1 元素。

最大 logprobs 值為5。
No None
max_tokens 整數 完成過程中可產生的最大代幣數量。

你的提示 max_tokens 詞的標記數不能超過模型的上下文長度。
No 16
n 整數 每個提示要產生多少個完成題。

註: 由於這個參數會產生許多完成任務,它可能會迅速消耗你的代幣配額。 謹慎使用,並確保你對 和 max_tokens的設定stop合理。
No 1
presence_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新代幣是否出現在文本中來懲罰,增加模型談論新主題的可能性。
No 0
seed 整數 若有指定,系統會盡力以確定性方式取樣,使得重複請求與參數相同 seed 時應返回相同結果。

確定性並非保證,你應該參考 system_fingerprint 回應參數來監控後端的變化。
No
stop 字串或陣列 最多有四個序列,API 會停止產生更多代幣。 回傳的文字不會包含停止音序列。
No
串流 boolean 是否要回溯部分進度。 若設定為此,代幣將以僅資料伺服器 發送的事件 形式在有可用時傳送,串流會以訊息終止 data: [DONE] No False
suffix 字串 插入文字完成後的後綴。

此參數僅支援於 gpt-3.5-turbo-instruct
No None
temperature number 取樣溫度該用什麼?介於0到2之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。

我們通常建議改變這個或 top_p 兩者都做。
No 1
top_p number 另一種以溫度抽樣為基礎的替代方案稱為核抽樣,模型考慮以top_p機率質量計算的符號結果。 因此 0.1 表示只考慮包含前 10 個% 機率質量的代幣。

我們通常建議改變這個或 temperature 兩者都做。
No 1
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。
No

createCompletionResponse

代表 API 的補全回應。 注意:串流與非串流回應物件的形狀相同(與聊天端點不同)。

Name 類型 Description Required Default
id 字串 完成的唯一識別碼。 Yes
choices 陣列 模型為輸入提示產生的完成選項清單。 Yes
created 整數 Unix 的時間戳記(以秒計)顯示完成完成的建立時間。 Yes
型號 字串 用於完備的模型。 Yes
prompt_filter_results promptFilterResults 針對請求中零或多個提示的內容篩選結果。 在串流請求中,不同提示的結果可能在不同時間或順序出現。 No
system_fingerprint 字串 這個指紋代表模型所使用的後端配置。

可與請求參數結合使用 seed ,以了解何時後端變更可能影響確定性。
No
物件 列舉 物件類型,永遠是「text_completion」
可能的數值:text_completion
Yes
使用方式 completionUsage 完成請求的使用統計數據。 No

createChatCompletionRequest

Name 類型 Description Required Default
temperature number 取樣溫度該用什麼?介於0到2之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。

我們通常建議改變這個或 top_p 兩者都做。
No 1
top_p number 另一種以溫度抽樣為基礎的替代方案稱為核抽樣,模型考慮以top_p機率質量計算的符號結果。 因此 0.1 表示只考慮包含前 10 個% 機率質量的代幣。

我們通常建議改變這個或 temperature 兩者都做。
No 1
串流 boolean 若設定為此,會傳送部分訊息 delta,類似 ChatGPT 中的訊息。 代幣將以僅資料伺服器 發送的事件 形式在有空時發送,串流會 data: [DONE] 以訊息終止。 No False
stop 字串或陣列 最多有四個序列,API 會停止產生更多代幣。
No
max_tokens 整數 聊天完成時能產生的最大代幣數量。

輸入標記與產生標記的總長度受模型上下文長度限制。
No
max_completion_tokens 整數 完成化可產生的標記數量上限,包括可見輸出標記與推理標記。 No
presence_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新代幣是否出現在文本中來懲罰,增加模型談論新主題的可能性。
No 0
frequency_penalty number 數字介於 -2.0 到 2.0 之間。 正值會根據新標記在文本中現有的頻率來懲罰,降低模型逐字重複同一行的可能性。
No 0
logit_bias 物件 修改特定標記出現在完成項目中的可能性。

接受一個 JSON 物件,將代幣(由代幣化器中由其 token ID 指定)映射到從 -100 到 100 的偏向值。 數學上,偏差會加到模型產生的對數值上,然後再進行抽樣。 具體效果會因模型而異,但介於 -1 與1之間的數值應降低或增加被選中的機率;像 -100 或 100 這類數值應該會導致封鎖或專屬選擇相關代幣。
No None
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。
No
messages 陣列 這是目前對話內容的清單。 Yes
data_sources 陣列 Azure OpenAI 聊天擴充功能的設定項目。
此額外規範僅與 Azure OpenAI 相容。
No
logprobs boolean 是否要回傳輸出標記的對數機率。 若為真,則回傳每個輸出符號在 contentmessage對數機率。 No False
top_logprobs 整數 一個介於0到20之間的整數,表示每個標記位置最可能回傳的標記數量,每個標記具有對數機率。 logprobs 若使用此參數,必須設定為 true No
n 整數 每則輸入訊息要產生多少個聊天結束選項。 請注意,你將根據所有選項中產生的代幣數量收費。 盡量降低n1成本。 No 1
parallel_tool_calls ParallelToolCalls 是否在工具使用時啟用平行函式呼叫。 No True
response_format ResponseFormatTextResponseFormatJsonObjectResponseFormatJsonSchema 一個指定模型必須輸出格式的物件。 相容於 GPT-4oGPT-4o miniGPT-4 Turbo 以及所有更新於 Tar 的 gpt-3.5-turbo-1106 Turbo 模型。

設定為 { "type": "json_schema", "json_schema": {...} } 啟用結構化輸出,保證模型會符合你提供的 JSON 架構。

設定啟用 { "type": "json_object" } JSON 模式,保證模型產生的訊息是有效的 JSON。

重要提示: 使用 JSON 模式時, 你也必須 指示模型透過系統或使用者訊息自行產生 JSON。 若無此,模型可能會產生無盡的空白流,直到產生達到代幣上限,導致請求長時間且看似「卡住」。 另外請注意,若 finish_reason="length",訊息內容可能會部分中斷,表示產生 max_tokens 次數或對話超過最大上下文長度。
No
seed 整數 此功能目前仍處於測試階段。
若有指定,系統會盡力以確定性方式取樣,使得重複請求與參數相同 seed 時應返回相同結果。
確定性並非保證,你應該參考 system_fingerprint 回應參數來監控後端的變化。
No
tools 陣列 模型可能呼叫的工具清單。 目前僅支援函式作為工具。 利用此資料提供模型可能產生 JSON 輸入的函式清單。 最多支援 128 個函式。
No
tool_choice chatCompletionToolChoiceOption 控制模型呼叫哪個(如果有)工具。 none 這表示模型不會呼叫任何工具,而是產生訊息。 auto 表示模型可以選擇產生訊息或呼叫一個或多個工具。 required 表示模型必須呼叫一個或多個工具。 指定特定工具 透過 會 {"type": "function", "function": {"name": "my_function"}} 強制模型呼叫該工具。 none 當沒有工具時,預設是。 auto 如果有工具,則是預設。 No
function_call string 或 chatCompletionFunctionCallOption 已被棄用,改為 tool_choice

控制模型呼叫哪個函式(若有的話)。
none 表示模型不會呼叫函式,而是產生訊息。
auto 表示模型可以選擇產生訊息或呼叫函式。
指定特定函數 會 {"name": "my_function"} 迫使模型呼叫該函數。

none 當沒有函式存在時,是預設值。 auto 若函式存在,則為預設值。
No
functions 陣列 已被棄用,改為 tools

模型可能產生 JSON 輸入的函數清單。
No

chatCompletionFunctions

Name 類型 Description Required Default
description 字串 描述函式的功能,模型用來決定何時以及如何呼叫函式。 No
name 字串 要呼叫的函式名稱。 必須是 a-z、A-Z、0-9,或包含底線和破折號,長度最多為 64。 Yes
parameters FunctionParameters 函式所接受的參數,描述為 JSON Schema 物件。 請參閱範例指南 ,以及 JSON Schema 參考資料 中關於格式的文件。

省略 parameters 定義了一個參數列表為空的函數。
No

chatCompletionFunctionCallOption

指定特定函數 會 {"name": "my_function"} 迫使模型呼叫該函數。

Name 類型 Description Required Default
name 字串 要呼叫的函式名稱。 Yes

chatCompletionRequestMessage

此組件可為以下之一:

chatCompletionRequestSystemMessage

Name 類型 Description Required Default
內容 字串或陣列 系統訊息的內容。 Yes
角色 列舉 訊息作者的角色,在此例 system中。
可能的值:系統
Yes
name 字串 參與者的可選名字。 提供模型資訊以區分同一角色的參與者。 No

chatCompletionRequestUserMessage

Name 類型 Description Required Default
內容 字串或陣列 使用者訊息的內容。
Yes
角色 列舉 訊息作者的角色,在此例 user中。
可能的值:使用者
Yes
name 字串 參與者的可選名字。 提供模型資訊以區分同一角色的參與者。 No

chatCompletionRequestAssistantMessage

Name 類型 Description Required Default
內容 字串或陣列 助理訊息的內容。 除非tool_callsfunction_call有規定或是必須的。
No
refusal 字串 助理的拒絕訊息。 No
角色 列舉 訊息作者的角色,在此例 assistant中。
可能的值:助理
Yes
name 字串 參與者的可選名字。 提供模型資訊以區分同一角色的參與者。 No
tool_calls chatCompletionMessageToolCalls 模型產生的工具呼叫,例如函式呼叫。 No
function_call 物件 已棄用並被 tool_calls取代。 模型產生的函式名稱與參數。 No

function_call 的性質

arguments

Name 類型 Description Default
arguments 字串 呼叫函式的參數,由模型以 JSON 格式產生。 請注意,模型不一定會產生有效的 JSON,且可能產生非函式結構定義的參數。 在呼叫函式前,先驗證程式碼中的參數。

name

Name 類型 Description Default
name 字串 要呼叫的函式名稱。

chatCompletionRequestToolMessage

Name 類型 Description Required Default
角色 列舉 訊息作者的角色,在此例 tool中。
可能的值:工具
Yes
內容 字串或陣列 工具訊息的內容。 Yes
tool_call_id 字串 這個訊息正在回應的工具呼叫。 Yes

chatCompletionRequestFunctionMessage

Name 類型 Description Required Default
角色 列舉 訊息作者的角色,在此例 function中。
可能的值:函數
Yes
內容 字串 函式訊息的內容。 Yes
name 字串 要呼叫的函式名稱。 Yes

chatCompletionRequestSystemMessageContentPart

此組件可為以下之一:

chatCompletionRequestUserMessageContentPart

此組件可為以下之一:

chatCompletionRequestAssistantMessageContentPart

此組件可為以下之一:

chatCompletionRequestToolMessageContentPart

此組件可為以下之一:

chatCompletionRequestMessageContentPartText

Name 類型 Description Required Default
型別 列舉 內容的類型。
可能的值:文字
Yes
收發簡訊 字串 文字內容。 Yes

chatCompletionRequestMessageContentPartImage

Name 類型 Description Required Default
型別 列舉 內容的類型。
可能數值:image_url
Yes
image_url 物件 Yes

image_url性質

url

Name 類型 Description Default
url 字串 圖片的網址或 base64 編碼的影像資料。

detail

Name 類型 Description Default
detail 字串 指定影像的細節等級。 在《 願景指南》中了解更多。 auto

chatCompletionRequestMessageContentPartRefusal

Name 類型 Description Required Default
型別 列舉 內容的類型。
可能的價值觀:拒絕
Yes
refusal 字串 模型產生的拒絕訊息。 Yes

azureChatExtensionConfiguration

一個針對單一 Azure OpenAI 聊天擴充的配置資料表示。 這將用於聊天完成請求,該請求應使用 Azure OpenAI 聊天擴充功能來增強回應行為。 此配置僅與 Azure OpenAI 相容。

Name 類型 Description Required Default
型別 azureChatExtensionType 一個針對單一 Azure OpenAI 聊天擴充的配置資料表示。 這會被聊天室使用。
完成請求應該使用 Azure OpenAI 聊天擴充功能來增強回應行為。
此配置僅與 Azure OpenAI 相容。
Yes

azureChatExtensionType

一個針對單一 Azure OpenAI 聊天擴充的配置資料表示。 這將用於聊天完成請求,該請求應使用 Azure OpenAI 聊天擴充功能來增強回應行為。 此配置僅與 Azure OpenAI 相容。

Description:單一 Azure OpenAI 聊天擴充功能的設定資料表示。 這將用於聊天完成請求,該請求應使用 Azure OpenAI 聊天擴充功能來增強回應行為。 此配置僅與 Azure OpenAI 相容。

Type: string

Default:

Enum name: AzureChatExtensionType

Enum Values:

Value Description
azure_search 代表使用 Azure Search 作為 Azure OpenAI 聊天擴充功能。
azure_cosmos_db 代表使用 Azure Cosmos DB 作為 Azure OpenAI 聊天擴充功能。

azureSearchChatExtensionConfiguration

這是使用 Azure 搜尋作為 Azure OpenAI 聊天擴充功能時,可設定選項的具體表示。

Name 類型 Description Required Default
型別 azureChatExtensionType 一個針對單一 Azure OpenAI 聊天擴充的配置資料表示。 這會被聊天室使用。
完成請求應該使用 Azure OpenAI 聊天擴充功能來增強回應行為。
此配置僅與 Azure OpenAI 相容。
Yes
parameters azureSearchChatExtensionParameters 當 Azure 搜尋作為 Azure OpenAI 聊天擴充功能時的參數。 No

azureSearchChatExtensionParameters

當 Azure 搜尋作為 Azure OpenAI 聊天擴充功能時的參數。

Name 類型 Description Required Default
認證 在 yourDataApiKeyAuthenticationOptionson yourDataSystemAssignedManagedIdentityAuthenticationOptionsonYourDataUserAssignedManagedIdentityAuthenticationOptions Yes
top_n_documents 整數 設定的最高文件數量,以供已設定的查詢功能。 No
in_scope boolean 查詢是否應該限制使用索引資料。 No
strictness 整數 搜尋相關性過濾的嚴格度。 嚴格度越高,答案的精確度越高但回憶力越低。 No
role_information 字串 給模型指示它應該如何行為,以及在產生回應時應參考的上下文。 你可以描述助理的個性,並告訴他如何格式化回應。 它有 100 個代幣的上限,且會計入整體代幣上限。 No
端點 字串 這是 Azure 搜尋資源的絕對端點路徑。 Yes
index_name 字串 在參考的 Azure 搜尋資源中,使用索引名稱。 Yes
fields_mapping azureSearchIndexFieldMappingOptions 可選設定,用來控制使用已設定的 Azure 搜尋資源時欄位的處理方式。 No
query_type azureSearchQueryType 使用 Azure 搜尋作為 Azure OpenAI 聊天擴充功能時,應該執行的查詢類型。 No
semantic_configuration 字串 查詢的額外語意配置。 No
篩選 字串 Search filter. No
embedding_dependency onYourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSource No

azureSearchIndexFieldMappingOptions

可選設定,用來控制使用已設定的 Azure 搜尋資源時欄位的處理方式。

Name 類型 Description Required Default
title_field 字串 用作標題的索引欄位名稱。 No
url_field 字串 索引欄位的名稱,作為網址。 No
filepath_field 字串 索引欄位名稱,作為檔案路徑。 No
content_fields 陣列 應該被視為內容的索引欄位名稱。 No
content_fields_separator 字串 內容欄位應該使用的分隔符模式。 No
vector_fields 陣列 代表向量資料的欄位名稱。 No

azureSearchQueryType

使用 Azure 搜尋作為 Azure OpenAI 聊天擴充功能時,應該執行的查詢類型。

Description:作為 Azure OpenAI 聊天擴充功能使用時,應執行的 Azure 搜尋檢索查詢類型。

Type: string

Default:

Enum Name: AzureSearchQueryType

Enum Values:

Value Description
simple 代表預設的簡單查詢解析器。
semantic 代表用於進階語意建模的語意查詢解析器。
向量 代表對計算資料進行向量搜尋。
vector_simple_hybrid 代表簡單查詢策略與向量資料的結合。
vector_semantic_hybrid 代表語意搜尋與向量資料查詢的結合。

azureCosmosDBChatExtensionConfiguration

這是使用 Azure Cosmos DB 作為 Azure OpenAI 聊天擴充功能時,可配置選項的具體表示。

Name 類型 Description Required Default
型別 azureChatExtensionType 一個針對單一 Azure OpenAI 聊天擴充的配置資料表示。 這會被聊天室使用。
完成請求應該使用 Azure OpenAI 聊天擴充功能來增強回應行為。
此配置僅與 Azure OpenAI 相容。
Yes
parameters azureCosmosDBChatExtensionParameters 配置 Azure OpenAI On Your Data 聊天擴展時使用 Azure Cosmos DB for 時使用的參數
MongoDB vCore.
No

azureCosmosDBChatExtensionParameters

配置 Azure OpenAI On Your Data 聊天擴展時使用的參數,使用 Azure Cosmos DB for MongoDB vCore 時。

Name 類型 Description Required Default
認證 onYourDataConnectionStringAuthenticationOptions 使用 連接字串 時,Azure OpenAI On Your Data 的認證選項。 Yes
top_n_documents 整數 設定的最高文件數量,以供已設定的查詢功能。 No
in_scope boolean 查詢是否應該限制使用索引資料。 No
strictness 整數 搜尋相關性過濾的嚴格度。 嚴格度越高,答案的精確度越高但回憶力越低。 No
role_information 字串 給模型指示它應該如何行為,以及在產生回應時應參考的上下文。 你可以描述助理的個性,並告訴他如何格式化回應。 它有 100 個代幣的上限,且會計入整體代幣上限。 No
database_name 字串 MongoDB vCore 資料庫名稱,用於 Azure Cosmos DB。 Yes
container_name 字串 Azure Cosmos DB 資源容器的名稱。 Yes
index_name 字串 MongoDB vCore 索引名稱,用於 Azure Cosmos DB。 Yes
fields_mapping azureCosmosDBFieldMappingOptions 可選設定,用來控制使用已設定 Azure Cosmos DB 資源時欄位的處理方式。 Yes
embedding_dependency onYourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSource Yes

azureCosmosDBFieldMappingOptions

可選設定,用來控制使用已設定 Azure Cosmos DB 資源時欄位的處理方式。

Name 類型 Description Required Default
title_field 字串 用作標題的索引欄位名稱。 No
url_field 字串 索引欄位的名稱,作為網址。 No
filepath_field 字串 索引欄位名稱,作為檔案路徑。 No
content_fields 陣列 應該被視為內容的索引欄位名稱。 Yes
content_fields_separator 字串 內容欄位應該使用的分隔符模式。 No
vector_fields 陣列 代表向量資料的欄位名稱。 Yes

onYourDataAuthenticationOptions

Azure OpenAI 在你資料上的認證選項。

Name 類型 Description Required Default
型別 onYourDataAuthenticationType Azure OpenAI 對你的資料所支援的認證類型。 Yes

onYourDataAuthenticationType

Azure OpenAI 對你的資料所支援的認證類型。

Description:OpenAI 對你的資料所支援的認證類型Azure。

Type: string

Default:

列舉名稱:OnYourDataAuthenticationType

Enum Values:

Value Description
api_key 透過 API 金鑰進行認證。
connection_string 透過 連接字串 進行認證。
system_assigned_managed_identity 透過系統指派的管理身份進行認證。
user_assigned_managed_identity 透過使用者指派的管理身份進行認證。

onYourDataApiKeyAuthenticationOptions

使用 API 金鑰時,Azure OpenAI 對你的資料的認證選項。

Name 類型 Description Required Default
型別 onYourDataAuthenticationType Azure OpenAI 對你的資料所支援的認證類型。 Yes
Key 字串 用於認證的 API 金鑰。 No

onYourDataConnectionStringAuthenticationOptions

使用 連接字串 時,Azure OpenAI On Your Data 的認證選項。

Name 類型 Description Required Default
型別 onYourDataAuthenticationType Azure OpenAI 對你的資料所支援的認證類型。 Yes
connection_string 字串 用來驗證的 連接字串。 No

onYourDataSystemAssignedManagedIdentityAuthenticationOptions

使用系統指派管理身份時,Azure OpenAI On Your Data 的認證選項。

Name 類型 Description Required Default
型別 onYourDataAuthenticationType Azure OpenAI 對你的資料所支援的認證類型。 Yes

onYourDataUserAssignedManagedIdentityAuthenticationOptions

使用使用者指派的管理身份時,Azure OpenAI 對你的資料的認證選項。

Name 類型 Description Required Default
型別 onYourDataAuthenticationType Azure OpenAI 對你的資料所支援的認證類型。 Yes
managed_identity_resource_id 字串 使用者指派的管理身份用於認證的資源 ID。 No

onYourDataVectorizationSource

Azure OpenAI 在你的資料上以向量搜尋為主題的向量化來源的抽象表示。

Name 類型 Description Required Default
型別 onYourDataVectorizationSourceType 代表 Azure OpenAI 對你的資料可用來源,用以配置資料向量化以供
vector search.
Yes

onYourDataVectorizationSourceType

代表 Azure OpenAI 對你的資料可用來源,用於配置向量搜尋所需的資料向量化。

Description:代表 OpenAI 對你的資料可用Azure來源,用以配置資料向量化以供
vector search.

Type: string

Default:

列舉名稱:OnYourDataVectorizationSourceType

Enum Values:

Value Description
端點 代表由公共服務呼叫至 Azure OpenAI 嵌入模型所執行的向量化。
deployment_name 代表一個 Ada 模型部署名稱。 這個模型部署必須在同一個 Azure OpenAI 資源中,但
On Your Data 將透過內部呼叫而非公開呼叫來部署此模型,從而實現向量
即使是在私人網路中也能搜尋

onYourDataDeploymentNameVectorizationSource

Azure OpenAI 在應用向量搜尋時所使用的向量化來源的細節,該來源基於同一 Azure OpenAI 資源中的內部嵌入模型部署名稱。

Name 類型 Description Required Default
型別 onYourDataVectorizationSourceType 代表 Azure OpenAI 對你的資料可用來源,用以配置資料向量化以供
vector search.
Yes
deployment_name 字串 指定用於向量化的模型部署名稱。 此模型部署必須在同一 Azure OpenAI 資源中,但 On Your Data 將透過內部呼叫而非公開呼叫使用此模型部署,這使得即使在私有網路中也能進行向量搜尋。 No

onYourDataEndpointVectorizationSource

Azure OpenAI 在應用向量搜尋時所使用的向量化來源的詳細資訊,該來源基於公開的 Azure OpenAI 端點嵌入呼叫。

Name 類型 Description Required Default
型別 onYourDataVectorizationSourceType 代表 Azure OpenAI 對你的資料可用來源,用以配置資料向量化以供
vector search.
Yes
認證 onYourDataApiKeyAuthenticationOptions 使用 API 金鑰時,Azure OpenAI 對你的資料的認證選項。 No
端點 字串 指定用於向量化的端點。 這個端點必須在同一 Azure OpenAI 資源中,但 On Your Data 會透過內部呼叫而非公開呼叫使用這個端點,這讓即使在私人網路中也能進行向量搜尋。 No

azureChatExtensionsMessageContext

這是當 Azure OpenAI 聊天擴充功能參與產生對應聊天完成回應時,所提供的額外上下文資訊的表示。 這些上下文資訊只有在使用 Azure OpenAI 請求並設定為匹配擴充功能時才會被填入。

Name 類型 Description Required Default
citations 陣列 資料來源檢索結果,用於產生回應中的助理訊息。 No
意圖 字串 聊天記錄中偵測到的意圖會傳遞到下一回合,以傳遞上下文。 No

citation

聊天完成回應訊息的引用資訊。

Name 類型 Description Required Default
內容 字串 表彰內容。 Yes
title 字串 表揚書的標題。 No
url 字串 引用的網址。 No
filepath 字串 引用的檔案路徑。 No
chunk_id 字串 罰單的區塊識別碼。 No

chatCompletionMessageToolCall

Name 類型 Description Required Default
id 字串 工具呼叫的ID。 Yes
型別 toolCallType 工具呼叫的類型,在此例 function中為 。 Yes
函式 物件 模型呼叫的函數。 Yes

函數性質

name

Name 類型 Description Default
name 字串 要呼叫的函式名稱。

arguments

Name 類型 Description Default
arguments 字串 呼叫函式的參數,由模型以 JSON 格式產生。 請注意,模型不一定會產生有效的 JSON,且可能產生非函式結構定義的參數。 在呼叫函式前,先驗證程式碼中的參數。

toolCallType

工具呼叫的類型,在此例 function中為 。

說明:工具呼叫的類型,在此例 function中為 。

Type: string

Default:

列舉名稱:ToolCallType

Enum Values:

Value Description
函式 工具呼叫類型是函數。

chatCompletionRequestMessageTool

Name 類型 Description Required Default
tool_call_id 字串 這個訊息正在回應的工具呼叫。 No
內容 字串 訊息內容。 No

chatCompletionRequestMessageFunction

Name 類型 Description Required Default
角色 列舉 訊息作者的角色,在此例 function中。
可能的值:函數
No
name 字串 訊息內容。 No
內容 字串 訊息內容。 No

createChatCompletionResponse

代表模型根據所提供輸入回傳的聊天完成回應。

Name 類型 Description Required Default
id 字串 聊天完成的唯一識別碼。 Yes
prompt_filter_results promptFilterResults 針對請求中零或多個提示的內容篩選結果。 在串流請求中,不同提示的結果可能在不同時間或順序出現。 No
choices 陣列 聊天完成選項列表。 如果 大於 1, n 則可以多於一個。 Yes
created 整數 Unix 的時間戳(以秒計)顯示聊天完成的時間點。 Yes
型號 字串 聊天完成所使用的模型。 Yes
system_fingerprint 字串 這個指紋代表模型所使用的後端配置。

可與請求參數結合使用 seed ,以了解何時後端變更可能影響確定性。
No
物件 列舉 物件類型,永遠 chat.completion為 。
可能的值:chat.completion
Yes
使用方式 completionUsage 完成請求的使用統計數據。 No

createChatCompletionStreamResponse

代表模型根據所提供輸入回傳的聊天完成回應串流片段。

Name 類型 Description Required Default
id 字串 聊天完成的唯一識別碼。 每個區塊的 ID 相同。 Yes
choices 陣列 聊天完成選項列表。 若 大於 1, n 則可包含多個元素。
Yes
created 整數 Unix 的時間戳(以秒計)顯示聊天完成的時間點。 每個區塊的時間戳記都一樣。 Yes
型號 字串 產生完備化的模型。 Yes
system_fingerprint 字串 這個指紋代表模型所使用的後端配置。
可與請求參數結合使用 seed ,以了解何時後端變更可能影響確定性。
No
物件 列舉 物件類型,永遠 chat.completion.chunk為 。
可能的值:chat.completion.chunk
Yes

chatCompletionStreamResponseDelta

由串流模型回應產生的聊天完成 delta。

Name 類型 Description Required Default
內容 字串 區塊訊息的內容。 No
function_call 物件 已棄用並被 tool_calls取代。 模型產生的函式名稱與參數。 No
tool_calls 陣列 No
角色 列舉 這則訊息作者的角色。
可能的值:系統、使用者、助理、工具
No
refusal 字串 模型產生的拒絕訊息。 No

function_call 的性質

arguments

Name 類型 Description Default
arguments 字串 呼叫函式的參數,由模型以 JSON 格式產生。 請注意,模型不一定會產生有效的 JSON,且可能產生非函式結構定義的參數。 在呼叫函式前,先驗證程式碼中的參數。

name

Name 類型 Description Default
name 字串 要呼叫的函式名稱。

chatCompletionMessageToolCallChunk

Name 類型 Description Required Default
索引 整數 Yes
id 字串 工具呼叫的ID。 No
型別 列舉 工具的種類。 目前僅 function 支援。
可能的值:函數
No
函式 物件 No

函數性質

name

Name 類型 Description Default
name 字串 要呼叫的函式名稱。

arguments

Name 類型 Description Default
arguments 字串 呼叫函式的參數,由模型以 JSON 格式產生。 請注意,模型不一定會產生有效的 JSON,且可能產生非函式結構定義的參數。 在呼叫函式前,先驗證程式碼中的參數。

chatCompletionStreamOptions

串流回應選項。 只有在你設定 stream: true時才會設定這個。

Name 類型 Description Required Default
include_usage boolean 若設定為此,訊息前 data: [DONE] 會再串流一個額外的區塊。 usage此區塊上的欄位顯示整個請求的代幣使用統計,且choices欄位永遠為空陣列。 其他區塊也會包含 usage 欄位,但值為空。
No

chatCompletionChoiceLogProbs

記錄選擇的機率資訊。

Name 類型 Description Required Default
內容 陣列 一份包含日誌機率資訊的訊息內容標記清單。 Yes
refusal 陣列 一份包含日誌機率資訊的訊息拒絕令牌清單。 No

chatCompletionTokenLogprob

Name 類型 Description Required Default
Token 字串 The token. Yes
logprob number 此標記的對數機率。 Yes
bytes 陣列 一個整數清單,代表 UTF-8 位元組的代幣表示。 當字元由多個標記表示,且必須組合其位元組表示以產生正確的文字表示時,非常有用。 如果代幣沒有位元組表示,可能會有 null 問題。 Yes
top_logprobs 陣列 在此標記位置上最可能出現的標記及其對數機率列表。 在極少數情況下,退回的數量可能少於申請 top_logprobs 的數量。 Yes

chatCompletionResponseMessage

由模型產生的聊天完成訊息。

Name 類型 Description Required Default
角色 chatCompletionResponseMessageRole 回應訊息作者的角色。 Yes
refusal 字串 模型產生的拒絕訊息。 Yes
內容 字串 訊息內容。 Yes
tool_calls 陣列 模型產生的工具呼叫,例如函式呼叫。 No
function_call chatCompletionFunctionCall 已棄用並被 tool_calls取代。 模型產生的函式名稱與參數。 No
內容 azureChatExtensionsMessageContext 這是當涉及 Azure OpenAI 聊天擴充時,所提供的額外上下文資訊的呈現
在產生對應的聊天完成回應時。 這些上下文資訊僅在
使用設定為匹配擴充功能的 Azure OpenAI 請求。
No

chatCompletionResponseMessageRole

回應訊息作者的角色。

說明:回應訊息作者的角色。

Type: string

Default:

Enum Values:

  • 助理

chatCompletionToolChoiceOption

控制模型呼叫哪個(如果有)工具。 none 這表示模型不會呼叫任何工具,而是產生訊息。 auto 表示模型可以選擇產生訊息或呼叫一個或多個工具。 required 表示模型必須呼叫一個或多個工具。 指定特定工具 透過 會 {"type": "function", "function": {"name": "my_function"}} 強制模型呼叫該工具。 none 當沒有工具時,預設是。 auto 如果有工具,則是預設。

此組件可為以下之一:

chatCompletionNamedToolChoice

指定模型應該使用的工具。 用來強制模型呼叫特定函式。

Name 類型 Description Required Default
型別 列舉 工具的種類。 目前僅 function 支援。
可能的值:函數
Yes
函式 物件 Yes

函數性質

name

Name 類型 Description Default
name 字串 要呼叫的函式名稱。

ParallelToolCalls

是否在工具使用時啟用平行函式呼叫。

此元件未定義屬性。

chatCompletionMessageToolCalls

模型產生的工具呼叫,例如函式呼叫。

此元件未定義屬性。

chatCompletionFunctionCall

已棄用並被 tool_calls取代。 模型產生的函式名稱與參數。

Name 類型 Description Required Default
name 字串 要呼叫的函式名稱。 Yes
arguments 字串 呼叫函式的參數,由模型以 JSON 格式產生。 請注意,模型不一定會產生有效的 JSON,且可能產生非函式結構定義的參數。 在呼叫函式前,先驗證程式碼中的參數。 Yes

completionUsage

完成請求的使用統計數據。

Name 類型 Description Required Default
prompt_tokens 整數 提示詞中的代幣數量。 Yes
completion_tokens 整數 生成完成項目中的代幣數量。 Yes
total_tokens 整數 請求中使用的總標記數(提示 + 完成數)。 Yes
completion_tokens_details 物件 完成過程中使用的代幣分解。 No

completion_tokens_details性質

reasoning_tokens

Name 類型 Description Default
reasoning_tokens 整數 由模型產生的推理代幣。

chatCompletionTool

Name 類型 Description Required Default
型別 列舉 工具的種類。 目前僅 function 支援。
可能的值:函數
Yes
函式 FunctionObject Yes

FunctionParameters

函式所接受的參數,描述為 JSON Schema 物件。 請參閱範例指南 ,以及 JSON Schema 參考資料 中關於格式的文件。

省略 parameters 定義了一個參數列表為空的函數。

此元件未定義屬性。

FunctionObject

Name 類型 Description Required Default
description 字串 描述函式的功能,模型用來決定何時以及如何呼叫函式。 No
name 字串 要呼叫的函式名稱。 必須是 a-z、A-Z、0-9,或包含底線和破折號,長度最多為 64。 Yes
parameters FunctionParameters 函式所接受的參數,描述為 JSON Schema 物件。 請參閱範例指南 ,以及 JSON Schema 參考資料 中關於格式的文件。

省略 parameters 定義了一個參數列表為空的函數。
No
strict boolean 在產生函式呼叫時是否要啟用嚴格的結構遵循。 若設為真,模型將遵循欄位中 parameters 定義的精確結構。 當 strict 為 時 true,僅支援部分 JSON 架構。 No False

ResponseFormatText

Name 類型 Description Required Default
型別 列舉 所定義的回應格式類型: text
可能的值:文字
Yes

ResponseFormatJsonObject

Name 類型 Description Required Default
型別 列舉 所定義的回應格式類型: json_object
可能數值:json_object
Yes

ResponseFormatJsonSchemaSchema

回應格式的結構,描述為 JSON Schema 物件。

此元件未定義屬性。

ResponseFormatJsonSchema

Name 類型 Description Required Default
型別 列舉 所定義的回應格式類型: json_schema
可能數值:json_schema
Yes
json_schema 物件 Yes

json_schema性質

description

Name 類型 Description Default
description 字串 描述回應格式的用途,模型用來決定如何以該格式回應。

name

Name 類型 Description Default
name 字串 回應格式的名稱。 必須是 a-z、A-Z、0-9,或包含底線和破折號,長度最多為 64。

結構描述

Name 類型 Description Default
結構描述 ResponseFormatJsonSchemaSchema 回應格式的結構,描述為 JSON Schema 物件。

strict

Name 類型 Description Default
strict boolean 在產生輸出時是否要啟用嚴格的結構遵循。 若設為 true,模型將始終遵循欄位中定義 schema 的精確模式。 當 strict 為 時 true,僅支援部分 JSON 架構。 False

chatCompletionChoiceCommon

Name 類型 Description Required Default
索引 整數 No
finish_reason 字串 No

createTranslationRequest

Translation request.

Name 類型 Description Required Default
檔案 字串 要翻譯的音訊檔案。 Yes
提示 字串 可選文字用來引導模型風格或延續先前的音訊片段。 題目應該是英文。 No
response_format audioResponseFormat 定義輸出格式。 No
temperature number 取樣溫度介於0到1之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。 若設為 0,模型會利用對數機率自動升溫,直到達到特定閾值。 No 0

audioResponse

當 response_format 是 json 時,翻譯或轉錄回應

Name 類型 Description Required Default
收發簡訊 字串 翻譯或轉錄文本。 Yes

audioVerboseResponse

翻譯或轉錄反應response_format verbose_json

Name 類型 Description Required Default
收發簡訊 字串 翻譯或轉錄文本。 Yes
工作 字串 音訊任務類型。 No
語言 字串 Language. No
duration number Duration. No
segments 陣列 No

audioResponseFormat

定義輸出格式。

說明:定義輸出格式。

Type: string

Default:

Enum Values:

  • json
  • 收發簡訊
  • srt
  • verbose_json
  • vtt

createTranscriptionRequest

Transcription request.

Name 類型 Description Required Default
檔案 字串 要轉錄的音訊檔案物件。 Yes
提示 字串 可選文字用來引導模型風格或延續先前的音訊片段。 提示詞應該與音頻語言相符。 No
response_format audioResponseFormat 定義輸出格式。 No
temperature number 取樣溫度介於0到1之間。 像 0.8 這樣的較高值會讓輸出更隨機,而像 0.2 這樣的低值則會讓輸出更聚焦且確定性強。 若設為 0,模型會利用對數機率自動升溫,直到達到特定閾值。 No 0
語言 字串 輸入音訊的語言。 以 ISO-639-1 格式提供輸入語言將提升準確度與延遲。 No

audioSegment

轉錄或翻譯片段。

Name 類型 Description Required Default
id 整數 Segment identifier. No
seek number 是段子的偏移。 No
start number 分段起始偏移。 No
end number 段端偏移。 No
收發簡訊 字串 Segment text. No
tokens 陣列 文字的標記。 No
temperature number Temperature. No
avg_logprob number 平均對數機率。 No
compression_ratio number Compression ratio. No
no_speech_prob number 機率 。no speech No

imageQuality

所產生的影像品質。

描述:將產生的影像品質。

Type: string

Default: standard

枚舉名稱:品質

Enum Values:

Value Description
標準 標準品質會產生標準品質的影像。
hd 高清畫質能創造出細節更細緻且整體一致性更高的影像。

imagesResponseFormat

產生影像回傳的格式。

說明:產生影像回傳的格式。

Type: string

Default: url

列舉名稱:ImagesResponseFormat

Enum Values:

Value Description
url 提供暫時下載生成影像的網址。
b64_json 產生的影像以 base64 編碼字串回傳。

imageSize

產生的影像大小。

描述:產生影像的大小。

Type: string

Default: 1024x1024

列舉名稱:大小

Enum Values:

Value Description
1792x1024 產生影像的期望尺寸為 1792x1024 像素。
1024x1792 產生影像的期望尺寸為 1024x1792 像素。
1024x1024 產生影像的期望尺寸為 1024x1024 像素。

imageStyle

產生的圖片風格。

說明:生成圖片的風格。

Type: string

Default: vivid

枚舉名稱:風格

Enum Values:

Value Description
vivid Vivid 創造出超寫實且戲劇化的影像。
natural 自然的影像更自然,且不那麼過寫實。

imageGenerationsRequest

Name 類型 Description Required Default
提示 字串 這是想要圖片的文字描述。 最大長度為4,000字元。 Yes
n 整數 要產生的影像數量。 No 1
size imageSize 產生的影像大小。 No 1024x1024
response_format imagesResponseFormat 產生影像回傳的格式。 No url
使用者 字串 一個代表終端使用者的獨特識別碼,有助於監控和偵測濫用行為。 No
quality imageQuality 所產生的影像品質。 No 標準
樣式 imageStyle 產生的圖片風格。 No vivid

generateImagesResponse

Name 類型 Description Required Default
created 整數 Unix 的時間戳記是該操作建立的時刻。 Yes
資料 陣列 操作成功時,該操作的結果資料 Yes

imageResult

如果成功,請輸入圖片網址或編碼圖片,否則會報錯。

Name 類型 Description Required Default
url 字串 圖片網址。 No
b64_json 字串 base64 編碼影像 No
content_filter_results dalleContentFilterResults 關於內容過濾結果的資訊。 No
revised_prompt 字串 如果提示有任何修改,就是用來產生圖片的提示。 No
prompt_filter_results dalleFilterResults 關於內容過濾類別(仇恨、性、暴力、self_harm)、是否已被偵測到,以及嚴重程度等級(very_low、低、中、高,決定有害內容的強度與風險等級),以及是否已被過濾。 關於越獄內容與髒話的資訊,是否被偵測到,以及是否被過濾。 還有關於客戶封鎖名單的資訊(如果已經被過濾過)以及它的識別碼。 No

Completions extensions

完成擴充功能並非最新 Azure OpenAI 資料平面推論規範的 GA 版本。

Chatmessage

聊天訊息物件並非最新 Azure OpenAI 資料平面推論規範中 GA 版本的一部分。

文字轉語音(預覽)

目前尚未包含在最新的 Azure OpenAI GA 版本中,該版本的 Azure OpenAI 資料平面推論規範。此功能請參閱最新的 preview 版本。

Next steps

學習模型 ,以及使用 REST API 微調。 深入了解驅動 OpenAI 的底層模型Azure。