API Key Usage
Every request to the AIGEN API requires authentication via an API key. You can obtain one by creating an account on the AIGEN website.
Authentication Methods
Option 1: HTTP Header (Recommended)
Include your API key in the X-AIGEN-KEY header:
- cURL
- Python
- Node.js
curl -X POST 'https://api.aigen.online/aiscript/idcard/v3' \
-H 'X-AIGEN-KEY: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"image": "<base64_string>"}'
import requests
headers = {
"X-AIGEN-KEY": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {"image": "<base64_string>"}
res = requests.post(
"https://api.aigen.online/aiscript/idcard/v3",
json=data,
headers=headers
)
print(res.json())
const axios = require("axios");
const headers = { "X-AIGEN-KEY": "YOUR_API_KEY" };
const data = { image: "<base64_string>" };
axios
.post("https://api.aigen.online/aiscript/idcard/v3", data, { headers })
.then((res) => console.log(res.data))
.catch((err) => console.error(err.response.data));
Option 2: Query Parameter
Pass the API key as a query parameter named aigen_key:
curl 'https://api.aigen.online/aiscript/idcard/v3?aigen_key=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"image": "<base64_string>"}'
When to use query parameters
This method is useful in environments where custom HTTP headers are restricted, such as webhook integrations (e.g., LINE webhook) or no-code platforms.
Security Best Practices
- Keep your API key secret — Never expose it in client-side code, public repositories, or browser requests.
- Use environment variables — Store your API key in environment variables, not hardcoded in source code.
- Rotate compromised keys — If you suspect your key has been exposed, regenerate it immediately through the API management page.
- Restrict usage — Use separate API keys for development and production environments.
Error Responses
| HTTP Status | Description |
|---|---|
401 | Missing or invalid API key |
403 | API key does not have permission for this endpoint |
429 | API credit has been exhausted — top up your account to continue |