Skip to main content
TraceLM uses API key authentication. You need two keys to make API calls:
  1. OpenAI API Key - Your standard OpenAI API key (starts with sk-)
  2. 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

1

Create a Project

Log in to TraceLM and create a new project from the dashboard.
2

Generate API Key

Navigate to your project settings and click “Generate API Key”.
3

Copy the Key

Copy your new API key. It will start with lt_.
Your TraceLM API key is only shown once when created. Store it securely.

Using API Keys

Headers

Include both keys in your request headers:
curl -X POST "https://api.tracelm.ai/v1/chat/completions" \
  -H "Authorization: Bearer sk-your-openai-key" \
  -H "X-API-Key: lt_your-tracelm-key" \
  -H "Content-Type: application/json" \
  -d '{...}'
HeaderValue
AuthorizationBearer sk-your-openai-key
X-API-Keylt_your-tracelm-key

Environment Variables

We recommend storing your API keys as environment variables:
.env
OPENAI_API_KEY=sk-your-openai-key
TRACELM_API_KEY=lt_your-tracelm-key
import os
from tracelm import TraceLM

tracelm = TraceLM(
    api_key=os.environ["TRACELM_API_KEY"],
    openai_api_key=os.environ["OPENAI_API_KEY"]
)

Authentication Errors

Status CodeErrorCause
401invalid_api_keyOpenAI API key is invalid or missing
401invalid_tracelm_keyTraceLM API key is invalid or missing
403project_not_foundTraceLM API key doesn’t match any project
403key_disabledAPI key has been disabled

Security Best Practices

API keys should only be used on the server side. Never include them in JavaScript bundles served to browsers.
Store API keys in environment variables, not in source code.
Periodically generate new API keys and revoke old ones.
Use different projects/keys for development, staging, and production.