Authentication
Creating and managing API keys for the Carrot platform.
Every request to the Carrot API requires an API key. Keys authenticate both trace ingestion (via the SDK) and inference requests.
Creating a key
- Sign in to platform.carrotlabs.ai
- Navigate to API Keys in the sidebar
- Click Create Key and give it a descriptive name
- Copy the key immediately — it won't be shown again
Store your API key securely. If you lose it, create a new one and revoke the old one.
Using the key
With the Python SDK
Pass it to init() or set the CARROT_API_KEY environment variable:
import carrot_ai
carrot_ai.init(api_key="sk-...")export CARROT_API_KEY=sk-...If the environment variable is set, you can skip the init() call entirely.
With the inference API
Pass the key as a Bearer token in the Authorization header:
from openai import OpenAI
client = OpenAI(
base_url="https://api.carrotlabs.ai/v1",
api_key="sk-...",
)curl https://api.carrotlabs.ai/v1/chat/completions \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{"model": "my-model", "messages": [{"role": "user", "content": "Hi"}]}'Revoking a key
In the API Keys page, click the delete button next to any key. The key is immediately invalidated and requests using it will receive a 401 response.
Error responses
| Status | Meaning |
|---|---|
401 | Missing, invalid, or revoked API key |