Keep your API key secure! Your API key should be treated like a password. Never share it publicly or commit it to version control systems.
Using Your API Key
Include your API key in theAuthorization header of every API request using the Bearer authentication scheme:
Example Request
Authentication Errors
If authentication fails, refer to the ‘Errors’ page for details on error codes.Store API Keys Securely
Store your API key in environment variables rather than hardcoding it:- Python
- JavaScript
Python can not read from .env file by default. You have 2 options:
- Option 1: Add to machine env
- Option 2: Read with python-dotenv package
Python
API Key Management
Revoking Keys
Revoking a key immediately invalidates it. Any applications using the revoked key will stop working. You cannot revert this action.
OpenAI Compatibility
The Fortytwo API uses the same authentication format as OpenAI’s API. If you’re migrating from OpenAI, you can simply replace your OpenAI API key with a Fortytwo API key:Troubleshooting
If you experience authentication issues:- Verify that your API key is written correctly.
- Make sure that the
Authorizationheader is properly formatted. - Contact support through Discord .