> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aihubmix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 openai 官方庫中使用

此處為最新 OpenAI 套件的使用指引，大陸用戶可以**直連使用**，構建業務更省心。

<Tip>
  方法要點：只需要在 client 內部加入轉發的 `base_url` 和 AiHubMix 平台的[密鑰](https://aihubmix.com/token)。
  適用於 AiHubMix 平台的所有模型。
</Tip>

```py Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-***", # 換成你在 AiHubMix 生成的密鑰
    base_url="https://aihubmix.com/v1"
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-4o-mini",
)

print(chat_completion)
```

<Info>
  OpenAI 官方當前服務狀態 [查詢](https://status.openai.com/)
</Info>
