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

# Ví dụ Node.js

> Gọi Rock API bằng Node.js.

# Ví dụ Node.js

```js theme={null}
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.ROCK_API_KEY,
  baseURL: 'https://rockapi.ai/v1',
})

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

console.log(response.choices[0].message.content)
```

<Card title="Lấy API key" icon="key" href="https://rockapi.ai/keys">
  Đăng ký và tạo [API key](https://rockapi.ai/keys) trước khi chạy ví dụ này.
</Card>
