Authentication
The Zihin API supports two authentication methods: API Keys and JWT tokens.
API Key Authentication
For public endpoints and simple integrations.
Headers
X-Api-Key: zhn_live_xxxxx
Or as Bearer token:
Authorization: Bearer zhn_live_xxxxx
Example
curl -X POST https://llm.zihin.ai/api/v3/llm/public/call \
-H "X-Api-Key: zhn_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{"query": "Hello", "model": "auto"}'
Key Format
| Environment | Format | Example |
|---|---|---|
| Production | zhn_live_* | zhn_live_abc123 |
| Sandbox | zhn_test_* | zhn_test_xyz789 |
JWT Authentication
For multi-tenant applications with user context.
Required Headers
Authorization: Bearer <jwt-token>
x-tenant-id: <uuid>
x-agent-id: <uuid>
Content-Type: application/json
Example
curl -X POST https://llm.zihin.ai/api/v3/llm/call \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "x-tenant-id: 550e8400-e29b-41d4-a716-446655440000" \
-H "x-agent-id: 6ba7b810-9dad-11d1-80b4-00c04fd430c8" \
-H "Content-Type: application/json" \
-d '{"query": "Hello", "model": "auto"}'
Header Reference
| Header | Required | Description |
|---|---|---|
Authorization | Yes | JWT token from Supabase |
x-tenant-id | Yes | Tenant UUID for isolation |
x-agent-id | Yes | Agent UUID for tracking |
Content-Type | Yes | Must be application/json |
Endpoint Authentication Summary
| Endpoint | API Key | JWT |
|---|---|---|
/api/v3/llm/public/call | Yes | No |
/api/v3/llm/call | No | Yes |
/api/llm/models | No | No |
/api/health/* | No | No |
/api/agents/* | No | Yes |
/api/database-configs/* | No | Yes |
/api/telemetry/* | No | No |
Error Responses
Invalid API Key
{
"error": "invalid_api_key",
"message": "The provided API key is invalid or expired",
"status": "error"
}
Missing Authentication
{
"error": "authentication_required",
"message": "This endpoint requires authentication",
"status": "error"
}
Invalid JWT
{
"error": "invalid_token",
"message": "JWT token is invalid or expired",
"status": "error"
}