> ## 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>
