繁體中文
Python
from openai import OpenAI client = OpenAI( base_url="https://aihubmix.com/v1", api_key="AIHUBMIX_API_KEY" ) completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "你好"}] ) print(completion.choices[0].message)
{ "choices": [ { "message": { "role": "<string>", "content": "<string>" }, "finish_reason": "<string>" } ], "usage": { "prompt_tokens": 123, "completion_tokens": 123, "total_tokens": 123 } }
Enable users to interact with your API
os.getenv("AIHUBMIX_API_KEY")
Bearer 認證,需要在請求標頭中加入 Authorization: Bearer AIHUBMIX_API_KEY,可在 這裡 取得 API 金鑰
要使用的模型 ID,可在 模型廣場 查看
對話訊息列表,包含角色與內容資訊
顯示 子屬性
取樣溫度,控制輸出的隨機性,範圍 0-2,值越大隨機性越高
產生文字的最大長度,可依模型能力設定不同值
核取樣參數,控制輸出文字的多樣性
頻率懲罰參數,避免重複產生相似內容
存在懲罰參數,鼓勵產生新內容
是否啟用串流輸出,及時返回產生內容
搜尋模型的網路搜尋選項,僅支援特定搜尋模型
成功回應