API Authentication
All novastack API requests require authentication using an API Key.
Get API Key
- Log in to novastack Console
- Go to the API Keys page
- Click Create New Key
- Copy the generated API Key
⚠️ Important: API Key is only displayed once when created. Please save it securely. If lost, you need to regenerate it.
Using API Key
Pass in HTTP Header
http/authorization-header.http
Authorization: Bearer YOUR_API_KEYcURL Example
Set API_BASE_URL to https://api.novapai.ai/router/v1 before running the examples.
curl/list-models.sh
curl "$API_BASE_URL/models" \
-H "Authorization: Bearer YOUR_API_KEY"Python Example
examples/openai_client.py
import os
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url=os.environ["API_BASE_URL"]
)JavaScript Example
examples/list-models.js
const response = await fetch(`${process.env.API_BASE_URL}/models`, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});API Key Permissions
| Permission | Description |
|---|---|
read | Read model list, account information |
write | Create tasks, generate content |
delete | Delete tasks, files |
Security Best Practices
- ✅ Do not commit API Key to code repositories
- ✅ Do not hardcode API Key in client-side code
- ✅ Use environment variables to store API Key
- ✅ Regularly rotate API Key
- ✅ Use different API Keys for different environments
Environment Variable Configuration
.env.example
# Linux / macOS
export NOVASTACK_API_KEY="your-api-key-here"
export API_BASE_URL="your-api-base-url"
# Windows
set NOVASTACK_API_KEY=your-api-key-here
set API_BASE_URL=your-api-base-urlexamples/use-env.py
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("NOVASTACK_API_KEY"),
base_url=os.environ["API_BASE_URL"]
)Error Code Reference
| Status Code | Error Type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid request parameters |
| 401 | authentication_error | Invalid API Key |
| 429 | rate_limit_error | Request rate limit exceeded |
| 500 | server_error | Internal server error |
Error Response Example
responses/auth-error.json
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key"
}
}Next Steps
- Get Started with API — Make your first API call
- OpenAI Chat Completions — Chat API request fields
- Account Levels — Rate limits and tiers