> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/avnlp/vectordb/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment variables

> Complete reference for environment variables used in VectorDB configurations

VectorDB uses environment variables for API keys, connection strings, and deployment-specific settings. This reference documents all supported environment variables.

## Why environment variables?

Environment variables provide several benefits:

* **Security**: Keep credentials out of version control
* **Flexibility**: Change settings per environment without code changes
* **Portability**: Deploy the same config across dev, staging, and production
* **CI/CD integration**: Inject secrets from vault systems

## Variable syntax in configurations

VectorDB supports two environment variable patterns in YAML:

<CodeGroup>
  ```yaml Simple substitution theme={null}
  api_key: "${PINECONE_API_KEY}"
  # Returns empty string if not set
  ```

  ```yaml With default value theme={null}
  uri: "${MILVUS_URI:-http://localhost:19530}"
  # Returns default if MILVUS_URI not set
  ```

  ```yaml Multiple substitutions theme={null}
  connection_string: "http://${HOST}:${PORT}"
  # Substitutes both variables
  ```
</CodeGroup>

## Vector database credentials

### Pinecone

<ParamField path="PINECONE_API_KEY" type="string" required>
  API key for Pinecone authentication. Get from [Pinecone console](https://app.pinecone.io/).

  **Example:**

  ```bash theme={null}
  export PINECONE_API_KEY="pc-abcd1234..."
  ```

  **Usage in config:**

  ```yaml theme={null}
  pinecone:
    api_key: "${PINECONE_API_KEY}"
  ```
</ParamField>

### Weaviate

<ParamField path="WEAVIATE_URL" type="string" required>
  Weaviate cluster URL including protocol and port.

  **Example:**

  ```bash theme={null}
  export WEAVIATE_URL="https://my-cluster.weaviate.network"
  ```

  **Usage in config:**

  ```yaml theme={null}
  weaviate:
    cluster_url: "${WEAVIATE_URL}"
  ```
</ParamField>

<ParamField path="WEAVIATE_API_KEY" type="string" required>
  API key for Weaviate authentication.

  **Example:**

  ```bash theme={null}
  export WEAVIATE_API_KEY="weaviate-api-key-abc123"
  ```

  **Usage in config:**

  ```yaml theme={null}
  weaviate:
    api_key: "${WEAVIATE_API_KEY}"
  ```
</ParamField>

### Milvus

<ParamField path="MILVUS_URI" type="string" required>
  Milvus connection URI including protocol, host, and port.

  **Example:**

  ```bash theme={null}
  export MILVUS_URI="http://localhost:19530"
  # or for cloud deployment:
  export MILVUS_URI="https://milvus-prod.example.com:19530"
  ```

  **Usage in config:**

  ```yaml theme={null}
  milvus:
    uri: "${MILVUS_URI:-http://localhost:19530}"
  ```
</ParamField>

<ParamField path="MILVUS_TOKEN" type="string">
  Authentication token for Milvus (required for managed instances).

  **Example:**

  ```bash theme={null}
  export MILVUS_TOKEN="milvus-token-xyz789"
  ```

  **Usage in config:**

  ```yaml theme={null}
  milvus:
    token: "${MILVUS_TOKEN:-}"
  ```
</ParamField>

### Qdrant

<ParamField path="QDRANT_URL" type="string" required>
  Qdrant server URL including protocol, host, and port.

  **Example:**

  ```bash theme={null}
  export QDRANT_URL="http://localhost:6333"
  # or for cloud:
  export QDRANT_URL="https://qdrant-prod.example.com:6333"
  ```

  **Usage in config:**

  ```yaml theme={null}
  qdrant:
    url: "${QDRANT_URL:-http://localhost:6333}"
  ```
</ParamField>

<ParamField path="QDRANT_API_KEY" type="string">
  API key for Qdrant authentication (required for cloud deployments).

  **Example:**

  ```bash theme={null}
  export QDRANT_API_KEY="qdrant-key-abc123"
  ```

  **Usage in config:**

  ```yaml theme={null}
  qdrant:
    api_key: "${QDRANT_API_KEY:-}"
  ```
</ParamField>

<ParamField path="QDRANT_HOST" type="string">
  Alternative: Qdrant host (used with QDRANT\_PORT).

  **Example:**

  ```bash theme={null}
  export QDRANT_HOST="localhost"
  export QDRANT_PORT="6333"
  ```
</ParamField>

<ParamField path="QDRANT_PORT" type="string">
  Qdrant port number (used with QDRANT\_HOST).

  **Default:** `6333`
</ParamField>

### Chroma

<ParamField path="CHROMA_HOST" type="string">
  Chroma server host for client/server mode.

  **Example:**

  ```bash theme={null}
  export CHROMA_HOST="localhost"
  ```

  **Usage in config:**

  ```yaml theme={null}
  chroma:
    host: "${CHROMA_HOST:-localhost}"
  ```
</ParamField>

<ParamField path="CHROMA_PORT" type="string">
  Chroma server port.

  **Example:**

  ```bash theme={null}
  export CHROMA_PORT="8000"
  ```

  **Default:** `8000`
</ParamField>

<ParamField path="CHROMA_PERSIST_DIR" type="string">
  Directory for Chroma local persistence.

  **Example:**

  ```bash theme={null}
  export CHROMA_PERSIST_DIR="./chroma_data"
  ```

  **Usage in config:**

  ```yaml theme={null}
  chroma:
    path: "${CHROMA_PERSIST_DIR:-./chroma_data}"
  ```
</ParamField>

## LLM API keys

### Groq

<ParamField path="GROQ_API_KEY" type="string" required>
  API key for Groq LLM services. Get from [Groq console](https://console.groq.com/).

  **Example:**

  ```bash theme={null}
  export GROQ_API_KEY="gsk_abc123..."
  ```

  **Usage in config:**

  ```yaml theme={null}
  rag:
    api_key: "${GROQ_API_KEY}"
    model: "llama-3.3-70b-versatile"
  ```
</ParamField>

### OpenAI

<ParamField path="OPENAI_API_KEY" type="string" required>
  API key for OpenAI services.

  **Example:**

  ```bash theme={null}
  export OPENAI_API_KEY="sk-proj-..."
  ```

  **Usage in config:**

  ```yaml theme={null}
  rag:
    provider: "openai"
    api_key: "${OPENAI_API_KEY}"
    model: "gpt-4-turbo-preview"
  ```
</ParamField>

### Cohere

<ParamField path="COHERE_API_KEY" type="string">
  API key for Cohere reranking services.

  **Example:**

  ```bash theme={null}
  export COHERE_API_KEY="cohere-key-xyz"
  ```

  **Usage in config:**

  ```yaml theme={null}
  reranker:
    type: "cohere"
    cohere_api_key: "${COHERE_API_KEY}"
  ```
</ParamField>

## Application settings

<ParamField path="LOG_LEVEL" type="string">
  Logging level for the application.

  **Values:** `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`

  **Example:**

  ```bash theme={null}
  export LOG_LEVEL="WARNING"
  ```

  **Default:** `INFO`

  **Usage in config:**

  ```yaml theme={null}
  logging:
    level: "${LOG_LEVEL:-INFO}"
  ```
</ParamField>

<ParamField path="ENVIRONMENT" type="string">
  Deployment environment identifier.

  **Values:** `development`, `staging`, `production`

  **Example:**

  ```bash theme={null}
  export ENVIRONMENT="production"
  ```

  **Usage in code:**

  ```python theme={null}
  import os
  env = os.getenv("ENVIRONMENT", "development")
  config_path = f"configs/{env}.yaml"
  ```
</ParamField>

<ParamField path="ENABLE_TELEMETRY" type="boolean">
  Enable telemetry and metrics collection.

  **Example:**

  ```bash theme={null}
  export ENABLE_TELEMETRY="true"
  ```

  **Default:** `false`
</ParamField>

<ParamField path="MAX_RETRIES" type="integer">
  Maximum retry attempts for failed operations.

  **Example:**

  ```bash theme={null}
  export MAX_RETRIES="3"
  ```

  **Default:** `3`
</ParamField>

<ParamField path="TIMEOUT_SECONDS" type="integer">
  Default timeout for API requests in seconds.

  **Example:**

  ```bash theme={null}
  export TIMEOUT_SECONDS="30"
  ```

  **Default:** `30`
</ParamField>

## Setting environment variables

### Local development (.env file)

Create a `.env` file in your project root:

```bash .env theme={null}
# Vector Databases
PINECONE_API_KEY=pc-dev-xxxx
WEAVIATE_URL=http://localhost:8080
WEAVIATE_API_KEY=dev-key
MILVUS_URI=http://localhost:19530
QDRANT_URL=http://localhost:6333
CHROMA_PERSIST_DIR=./chroma_data

# LLM APIs
GROQ_API_KEY=gsk_dev_xxxx
OPENAI_API_KEY=sk-dev-xxxx

# Application
LOG_LEVEL=INFO
ENVIRONMENT=development
```

Load with python-dotenv:

```python theme={null}
from dotenv import load_dotenv
import os

load_dotenv()

api_key = os.getenv("PINECONE_API_KEY")
```

### Shell export

```bash theme={null}
export PINECONE_API_KEY="pc-prod-xxxx"
export GROQ_API_KEY="gsk_prod_xxxx"
export LOG_LEVEL="WARNING"
```

### Docker

```bash theme={null}
docker run \
  -e PINECONE_API_KEY="pc-prod-xxxx" \
  -e GROQ_API_KEY="gsk_prod_xxxx" \
  -e LOG_LEVEL="WARNING" \
  my-vectordb-app
```

Or use an env file:

```bash theme={null}
docker run --env-file .env.production my-vectordb-app
```

### Docker Compose

```yaml docker-compose.yml theme={null}
services:
  vectordb:
    image: my-vectordb-app
    env_file:
      - .env.production
    environment:
      - ENVIRONMENT=production
      - LOG_LEVEL=WARNING
```

### Kubernetes secrets

```yaml secrets.yaml theme={null}
apiVersion: v1
kind: Secret
metadata:
  name: vectordb-secrets
type: Opaque
stringData:
  pinecone-api-key: "pc-prod-xxxx"
  groq-api-key: "gsk_prod_xxxx"
  weaviate-api-key: "weaviate-prod-key"
```

```yaml deployment.yaml theme={null}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vectordb-app
spec:
  template:
    spec:
      containers:
      - name: app
        image: my-vectordb-app
        env:
        - name: PINECONE_API_KEY
          valueFrom:
            secretKeyRef:
              name: vectordb-secrets
              key: pinecone-api-key
        - name: GROQ_API_KEY
          valueFrom:
            secretKeyRef:
              name: vectordb-secrets
              key: groq-api-key
        - name: LOG_LEVEL
          value: "WARNING"
```

### GitHub Actions

```yaml .github/workflows/test.yml theme={null}
name: Test

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Run tests
        env:
          PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
          GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
          LOG_LEVEL: INFO
        run: |
          pytest tests/
```

## Environment-specific configuration pattern

Organize variables by environment:

<CodeGroup>
  ```bash .env.development theme={null}
  PINECONE_API_KEY=pc-dev-xxxx
  GROQ_API_KEY=gsk_dev_xxxx
  LOG_LEVEL=DEBUG
  ENVIRONMENT=development
  MILVUS_URI=http://localhost:19530
  QDRANT_URL=http://localhost:6333
  ```

  ```bash .env.staging theme={null}
  PINECONE_API_KEY=pc-staging-xxxx
  GROQ_API_KEY=gsk_staging_xxxx
  LOG_LEVEL=INFO
  ENVIRONMENT=staging
  MILVUS_URI=https://milvus-staging.example.com:19530
  QDRANT_URL=https://qdrant-staging.example.com:6333
  ```

  ```bash .env.production theme={null}
  PINECONE_API_KEY=pc-prod-xxxx
  GROQ_API_KEY=gsk_prod_xxxx
  LOG_LEVEL=WARNING
  ENVIRONMENT=production
  MILVUS_URI=https://milvus-prod.example.com:19530
  QDRANT_URL=https://qdrant-prod.example.com:6333
  ENABLE_TELEMETRY=true
  ```
</CodeGroup>

Load environment-specific file:

```python theme={null}
import os
from dotenv import load_dotenv

env = os.getenv("ENVIRONMENT", "development")
load_dotenv(f".env.{env}")
```

## Security best practices

<AccordionGroup>
  <Accordion title="Never commit secrets">
    Add environment files to `.gitignore`:

    ```bash .gitignore theme={null}
    .env
    .env.*
    !.env.example
    ```

    Provide an example file with placeholders:

    ```bash .env.example theme={null}
    PINECONE_API_KEY=your-pinecone-api-key
    GROQ_API_KEY=your-groq-api-key
    MILVUS_URI=http://localhost:19530
    LOG_LEVEL=INFO
    ```
  </Accordion>

  <Accordion title="Use secret management systems">
    For production, use dedicated secret management:

    * **AWS Secrets Manager** or **Parameter Store**
    * **Google Cloud Secret Manager**
    * **Azure Key Vault**
    * **HashiCorp Vault**
    * **Kubernetes Secrets**

    Example with AWS Secrets Manager:

    ```python theme={null}
    import boto3
    import json

    def get_secret(secret_name):
        client = boto3.client('secretsmanager')
        response = client.get_secret_value(SecretId=secret_name)
        return json.loads(response['SecretString'])

    secrets = get_secret('vectordb/production')
    os.environ['PINECONE_API_KEY'] = secrets['pinecone_api_key']
    os.environ['GROQ_API_KEY'] = secrets['groq_api_key']
    ```
  </Accordion>

  <Accordion title="Rotate credentials regularly">
    * Set up automatic key rotation (monthly or quarterly)
    * Monitor for leaked credentials using tools like GitGuardian
    * Revoke old keys after rotation
    * Test new credentials before revoking old ones
  </Accordion>

  <Accordion title="Validate required variables">
    Check that required variables are set at startup:

    ```python theme={null}
    import os
    import sys

    required_vars = [
        "PINECONE_API_KEY",
        "GROQ_API_KEY",
    ]

    missing = [var for var in required_vars if not os.getenv(var)]

    if missing:
        print(f"Error: Missing required environment variables: {missing}")
        sys.exit(1)
    ```
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Variable not substituted">
    **Symptom:** Configuration shows `${VAR_NAME}` literal instead of value.

    **Solutions:**

    * Ensure variable is exported: `export VAR_NAME=value`
    * Check variable name spelling matches exactly
    * Verify `.env` file is loaded if using python-dotenv
    * Use default syntax: `${VAR_NAME:-default}` to see if default appears
  </Accordion>

  <Accordion title="Empty string instead of value">
    **Symptom:** Variable resolves to empty string.

    **Solutions:**

    * Variable is set but empty: `export VAR_NAME=`
    * Use `echo $VAR_NAME` to verify shell environment
    * Check for typos in variable name
    * Ensure export happens before running Python
  </Accordion>

  <Accordion title="Wrong environment loaded">
    **Symptom:** Production uses development credentials.

    **Solutions:**

    * Set `ENVIRONMENT` variable before loading config
    * Use explicit env file path: `load_dotenv('.env.production')`
    * Check which env file was loaded in logs
    * Verify Kubernetes/Docker env injection
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Configuration reference" icon="gear" href="/guides/configuration">
    See how to use these variables in YAML configs
  </Card>

  <Card title="Production deployment" icon="rocket" href="/guides/production-deployment">
    Learn production secrets management patterns
  </Card>

  <Card title="Building RAG pipelines" icon="wrench" href="/guides/building-rag-pipeline">
    Use environment variables in your first pipeline
  </Card>

  <Card title="Benchmarking" icon="chart-line" href="/guides/benchmarking">
    Set up evaluation environments
  </Card>
</CardGroup>
