Authentication
Secure your access to the MX4 Atlas API.
The MX4 Atlas API uses API keys for authentication. You must include your API key in the `Authorization` HTTP header of every request.
Authorization Header
Include the API key in the standard Bearer token format:
1Authorization: Bearer mx4-sk-YOUR_API_KEY
Handling API Keys
Security Warning
Your API key can perform any action on your account. Never share it, and never include it in client-side code (browsers, mobile apps).
We recommend loading your API key from environment variables.
1import os2import openai34# Good: Load from environment5client = openai.OpenAI(6 api_key=os.environ.get("MX4_API_KEY"),7 base_url="https://api.mx4.ai/v1"8)
Authentication Errors
| Status Code | Error Type | Description |
|---|---|---|
| 401 | Unauthorized | Your API key is missing or invalid. |
| 403 | Forbidden | You don't have permission to access this resource or model. |
Mutual TLS (mTLS)
For private cloud and air-gapped deployments, we support mutual TLS (mTLS) to ensure both client and server authenticate each other. It is strongly recommended for highly restricted environments.
1import openai2import os34client = openai.OpenAI(5 base_url="https://api.mx4.private/v1",6 api_key=os.environ.get("MX4_API_KEY"),7 # mTLS certificate paths8 http_client=httpx.Client(9 cert=("path/to/client.crt", "path/to/client.key"),10 verify="path/to/ca.crt"11 )12)1314response = client.chat.completions.create(15 model="mx4-atlas-core",16 messages=[{"role": "user", "content": "Hello"}]17)
Best Practices
Rotate Keys Regularly
Rotate keys on a regular cadence and use a staged rollover to avoid downtime.
Use Environment Variables
Never hardcode API keys in your source code. Use environment variables or a secrets manager like Vault.
Review Key Usage
Monitor API key usage and disable unused keys promptly. Review usage logs regularly.
Troubleshooting
❌ "Invalid API Key" Error
Check that your key starts with mx4-sk-, contains no whitespace, and is passed in the Authorization header as Bearer {key}.
❌ "Forbidden" With Valid Key
Your account may not have access to the model you're requesting. Check Atlas Studio or your account portal to see which models are available in your region/plan.
❌ Certificate Errors (mTLS)
Verify that your client certificate is signed by the CA and has not expired. Run openssl x509 -in cert.crt -text -noout to inspect.