Authentication and API keys
MoonNexAI API uses Bearer API Key authentication. All public API should take Authorization request head.
request head
http
Authorization: Bearer <MOONNEXAI_API_KEY>Create and manage API Key
- Login to MoonNexAI console.
- Enter the API Key management page.
- Select the use or grouping.
- Sets the name, the amount and the period of validity.
- Saves the key after creation and only uses it for service-end environment variables.
Service-Purpose Configuration
Suggests that API Key be placed in the service-end environment variable:
bash
MOONNEXAI_API_KEY=<MOONNEXAI_API_KEY>Node.js Example:
js
const apiKey = process.env.MOONNEXAI_API_KEYPython Example:
python
import os
api_key = os.environ["MOONNEXAI_API_KEY"]Group recommendations
| scene | Recommendations |
|---|---|
| Local development | Use of a separate API Key, which is lower and allows for rotation at any time. |
| Online service | Use of independent API Key, only models for business needs. |
| Client items | Each client or project uses a separate API Key to facilitate the counting and decommissioning of. |
| Temporary Test | Sets a shorter validity period and deletes it after the test. |
Security alarm
- Do not write API Key to frontend code, mobile end installation package or open warehouse.
- Do not place API Key in URL query.
- Documentation examples use
<MOONNEXAI_API_KEY>. - If the key appears in a chat record, log, screenshot or public page, it should rotate immediately.