Skip to Content
Getting StartedAPI Authentication

API Authentication

All novastack API requests require authentication using an API Key.

Get API Key

  1. Log in to novastack Console
  2. Go to the API Keys page
  3. Click Create New Key
  4. 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_KEY

cURL 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

PermissionDescription
readRead model list, account information
writeCreate tasks, generate content
deleteDelete 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-url
examples/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 CodeError TypeDescription
400invalid_request_errorInvalid request parameters
401authentication_errorInvalid API Key
429rate_limit_errorRequest rate limit exceeded
500server_errorInternal 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