Authentication
Copy Page as Markdown
Every API request requires an API key in the Authorization header using the
Bearer scheme.
Create an API key
Generate a key from console.subq.ai, store it outside your source tree, and send it with each request:
curl https://api.subq.ai/v1/chat/completions \
-H "Authorization: Bearer $SUBQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "subq-preview",
"messages": [
{ "role": "user", "content": "ping" }
]
}'Use environment variables
Set the key in your local shell or deployment environment:
export SUBQ_API_KEY="sk-your-api-key"Then read SUBQ_API_KEY from your application configuration and pass it to your
HTTP client or OpenAI SDK.
Key security
- Store securely. Keys are shown once at creation and cannot be retrieved later.
- Rotate regularly. Create new keys and revoke old ones from the console.
- Never commit to source control. Use environment variables or a secrets manager.