Overview
APITHON uses Bearer token authentication to secure access to the API Gateway. All requests to the/v1/chat/completions endpoint must include a valid authentication token in the Authorization header.
Authentication Method
Bearer Token
The API uses a simple Bearer token authentication scheme. The default API key is configured inapithon.py:29:
Authentication Check
Authentication is validated in theapithon_gateway function (apithon.py:134-136):
Authorization header to contain the exact string Bearer {API_KEY_GATEWAY}.
How to Authenticate
Including the Token
Include the Bearer token in theAuthorization header of your HTTP request:
Example Request
Error Responses
401 Unauthorized
If authentication fails, the API returns a401 Unauthorized status code with the following response:
- The
Authorizationheader is missing - The Bearer token is incorrect
- The header format is invalid
Security Considerations
Best Practices
- Change the Default Key: Modify the
API_KEY_GATEWAYvalue inapithon.py:29before deploying to production - Use Environment Variables: Store the API key in environment variables instead of hardcoding it
- Use HTTPS: Always use HTTPS in production to encrypt the Bearer token in transit
- Rotate Keys Regularly: Implement a key rotation policy for enhanced security
- Restrict Network Access: Use firewall rules to limit which IPs can access the API
Recommended Implementation
Instead of the hardcoded key, use environment variables:The authentication mechanism is intentionally simple for POC (Proof of Concept) purposes. For production use, consider implementing more robust authentication methods such as OAuth 2.0, JWT tokens, or API key management systems.
Next Steps
API Endpoints
Explore available API endpoints
Quick Start
Get started with APITHON