Carrot LabsCarrot Docs

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

  1. Sign in to platform.carrotlabs.ai
  2. Navigate to API Keys in the sidebar
  3. Click Create Key and give it a descriptive name
  4. 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

StatusMeaning
401Missing, invalid, or revoked API key

On this page