Authentication
GenRex uses API keys to authenticate requests. You can manage your API keys from your dashboard.
Getting an API Key
- Sign in to your GenRex dashboard
- Navigate to Developer in the sidebar
- Click Create API Key
- Give your key a descriptive name and copy it
Important
API keys are only shown once when created. Store them securely - you cannot retrieve them later.
API Key Format
GenRex API keys use the following format:
grx_sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
grx_sk_- Prefix identifying GenRex secret keys- Followed by 48 hexadecimal characters
- Total length: 55 characters
Using the API Key
Include your API key using one of these methods:
Authorization Header (recommended)
Authorization: Bearer grx_sk_your_api_key_here
X-API-Key Header
X-API-Key: grx_sk_your_api_key_here
Example Request
cURL
curl -X POST https://api.genrex.io/v1/document/create \
-H "Authorization: Bearer grx_sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"prompt": "Write about AI trends"}'
JavaScript (fetch)
const response = await fetch('https://api.genrex.io/v1/document/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer grx_sk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'Write about AI trends'
})
});
const data = await response.json();
PHP
$response = Http::withHeaders([
'Authorization' => 'Bearer grx_sk_your_api_key',
])->post('https://api.genrex.io/v1/document/create', [
'prompt' => 'Write about AI trends'
]);
$data = $response->json();
Authentication Errors
| Status | Code | Description |
|---|---|---|
401 |
UNAUTHENTICATED |
Missing authentication credentials |
401 |
INVALID_API_KEY |
API key is invalid or does not exist |
403 |
ACCOUNT_DISABLED |
Account is disabled |
402 |
INSUFFICIENT_CREDITS |
Account has insufficient credits |
Security Best Practices
- Never expose API keys in client-side code or public repositories
- Use environment variables to store API keys
- Rotate keys periodically and immediately if compromised
- Create separate keys for different applications or environments