- OpenAI API Key - Your standard OpenAI API key (starts with
sk-) - TraceLM API Key - Your project-specific TraceLM key (starts with
lt_)
Getting Your API Keys
OpenAI API Key
Get your OpenAI API key from the OpenAI dashboard.TraceLM API Key
Using API Keys
Headers
Include both keys in your request headers:| Header | Value |
|---|---|
Authorization | Bearer sk-your-openai-key |
X-API-Key | lt_your-tracelm-key |
Environment Variables
We recommend storing your API keys as environment variables:.env
- Python
- TypeScript
Authentication Errors
| Status Code | Error | Cause |
|---|---|---|
| 401 | invalid_api_key | OpenAI API key is invalid or missing |
| 401 | invalid_tracelm_key | TraceLM API key is invalid or missing |
| 403 | project_not_found | TraceLM API key doesn’t match any project |
| 403 | key_disabled | API key has been disabled |
Security Best Practices
Never expose keys in client-side code
Never expose keys in client-side code
API keys should only be used on the server side. Never include them in JavaScript bundles served to browsers.
Use environment variables
Use environment variables
Store API keys in environment variables, not in source code.
Rotate keys regularly
Rotate keys regularly
Periodically generate new API keys and revoke old ones.
Use separate keys per environment
Use separate keys per environment
Use different projects/keys for development, staging, and production.