Skip to main content

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

EnvironmentFormatExample
Productionzhn_live_*zhn_live_abc123
Sandboxzhn_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

HeaderRequiredDescription
AuthorizationYesJWT token from Supabase
x-tenant-idYesTenant UUID for isolation
x-agent-idYesAgent UUID for tracking
Content-TypeYesMust be application/json

Endpoint Authentication Summary

EndpointAPI KeyJWT
/api/v3/llm/public/callYesNo
/api/v3/llm/callNoYes
/api/llm/modelsNoNo
/api/health/*NoNo
/api/agents/*NoYes
/api/database-configs/*NoYes
/api/telemetry/*NoNo

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"
}