繁體中文
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 金鑰
成功回應
The response is of type object.
object