Authentication
Authenticate your requests using your HacxGPT API key.
API Key Format
HacxGPT API keys start with hk-proj- followed by a unique token. You can manage your keys from the HacxGPT dashboard.
Bearer Token (Recommended)
Pass your API key in the Authorization header as a Bearer token. This is the standard method and works with all OpenAI SDKs.
Header
Authorization: Bearer hk-proj-YOUR_API_KEYAlternative: x-api-key Header
You can also pass your API key using the x-api-key header.
Header
x-api-key: hk-proj-YOUR_API_KEYSDK Examples
from openai import OpenAI
# Option 1: Pass directly
client = OpenAI(
api_key="hk-proj-YOUR_API_KEY",
base_url="https://api.hacxgpt.com/v1"
)
# Option 2: Use environment variable
# export OPENAI_API_KEY="hk-proj-YOUR_API_KEY"
# export OPENAI_BASE_URL="https://api.hacxgpt.com/v1"
# client = OpenAI() # auto-configuredWarning
Never expose your API key in client-side code or public repositories. Always use environment variables and server-side code in production.