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

# Python 示例

> 使用 Python 调用 Rock API。

# Python 示例

```python theme={null}
from openai import OpenAI

client = OpenAI(api_key="YOUR_ROCK_API_KEY", base_url="https://rockapi.ai/v1")

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.choices[0].message.content)
```

<Card title="获取 API Key" icon="key" href="https://rockapi.ai/keys">
  运行示例前，请先注册并创建 [API Key](https://rockapi.ai/keys)。
</Card>
