Skip to main content
All requests to the Fortytwo API require authentication using an API key. This guide explains how to use and manage your API keys securely.
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 the Authorization 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 can not read from .env file by default. You have 2 options:
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 Authorization header is properly formatted.
  • Contact support through Discord .