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

# Environment Variables

> Complete reference for all environment variables used by Gnosis Prediction Market Agents

## Overview

The agent system uses environment variables for configuration, API credentials, and runtime settings. Variables can be set in a `.env` file, passed via command line, or configured in your deployment platform.

## Required Variables

These variables are required as a minimum to run any agent:

<ParamField path="BET_FROM_PRIVATE_KEY" type="string" required>
  Private key for the Ethereum wallet used to place bets and interact with prediction markets.

  **Format**: 64-character hexadecimal string (with or without `0x` prefix)

  <Warning>
    Never commit this to version control. Keep it secure and never share it.
  </Warning>
</ParamField>

<ParamField path="OPENAI_API_KEY" type="string" required>
  OpenAI API key for GPT model access.

  **Format**: `sk-...`

  Required for most agents that use language models for prediction and reasoning.
</ParamField>

## AI Model API Keys

Depending on which agent you run, you may need additional AI service API keys:

<ParamField path="OPENAI_API_KEY" type="string">
  OpenAI API key for GPT-4, GPT-4o, GPT-3.5, and o1 models.

  **Used by**:

  * `prophet_gpt4o`
  * `prophet_gpt4`
  * `prophet_gpt4omini`
  * `prophet_o1`
  * `prophet_o1mini`
  * `prophet_o3mini`
  * `microchain`
  * `think_thoroughly`
  * Most other agents
</ParamField>

<ParamField path="ANTHROPIC_API_KEY" type="string">
  Anthropic API key for Claude models.

  **Used by**:

  * `prophet_claude3_opus`
  * `prophet_claude35_haiku`
  * `prophet_claude35_sonnet`
</ParamField>

<ParamField path="GOOGLE_API_KEY" type="string">
  Google API key for Gemini models.

  **Used by**:

  * `prophet_gemini20flash`
</ParamField>

<ParamField path="DEEPSEEK_API_KEY" type="string">
  DeepSeek API key for DeepSeek models.

  **Used by**:

  * `prophet_deepseekchat`
  * `prophet_deepseekr1`
</ParamField>

## Research and Information API Keys

Agents use various APIs for research and information gathering:

<ParamField path="SERPER_API_KEY" type="string">
  Serper API key for Google Search integration.

  **Purpose**: Enables agents to search the web for information about markets

  **Get it**: [serper.dev](https://serper.dev)

  **Used by**: Research-intensive agents like `think_thoroughly`, `gptr_agent`
</ParamField>

<ParamField path="TAVILY_API_KEY" type="string">
  Tavily API key for AI-powered search.

  **Purpose**: Advanced search and information retrieval

  **Get it**: [tavily.com](https://tavily.com)

  **Used by**: Research agents, `think_thoroughly_prophet`
</ParamField>

<ParamField path="GRAPH_API_KEY" type="string">
  The Graph API key for querying blockchain data.

  **Purpose**: Access to indexed blockchain data and market information

  **Used by**: Agents that need historical market data
</ParamField>

## Social Media Integration

<ParamField path="FARCASTER_PRIVATE_KEY" type="string">
  Private key for Farcaster account.

  **Purpose**: Post predictions and insights to Farcaster

  **Used by**: `social_media` agent
</ParamField>

<ParamField path="TWITTER_API_KEY" type="string">
  Twitter API key (Consumer Key).

  **Used by**: `social_media` agent
</ParamField>

<ParamField path="TWITTER_API_KEY_SECRET" type="string">
  Twitter API key secret (Consumer Secret).

  **Used by**: `social_media` agent
</ParamField>

<ParamField path="TWITTER_ACCESS_TOKEN" type="string">
  Twitter access token for authenticated requests.

  **Used by**: `social_media` agent
</ParamField>

<ParamField path="TWITTER_ACCESS_TOKEN_SECRET" type="string">
  Twitter access token secret.

  **Used by**: `social_media` agent
</ParamField>

<ParamField path="TWITTER_BEARER_TOKEN" type="string">
  Twitter bearer token for API v2.

  **Used by**: `social_media` agent
</ParamField>

## Vector Database and Embeddings

<ParamField path="PINECONE_API_KEY" type="string">
  Pinecone API key for vector database operations.

  **Purpose**: Store and retrieve embeddings for semantic search

  **Used by**: `olas_embedding_oa`, agents using embedding-based retrieval
</ParamField>

## Database Configuration

<ParamField path="SQLALCHEMY_DB_URL" type="string">
  Database connection URL for SQLAlchemy.

  **Format**: `postgresql://user:password@host:port/database`

  **Purpose**: Persistent storage for agent state, market data, and analytics

  **Example**: `postgresql://agent:password@localhost:5432/prediction_agent`

  **Used by**: Agents that require persistent state, NFT treasury game agents
</ParamField>

## Observability and Monitoring

<ParamField path="LANGFUSE_SECRET_KEY" type="string">
  Langfuse secret key for authentication.

  **Purpose**: Track LLM calls, costs, and performance
</ParamField>

<ParamField path="LANGFUSE_PUBLIC_KEY" type="string">
  Langfuse public key for authentication.

  **Purpose**: Track LLM calls, costs, and performance
</ParamField>

<ParamField path="LANGFUSE_HOST" type="string">
  Langfuse host URL.

  **Default**: `https://cloud.langfuse.com`

  **Purpose**: Endpoint for Langfuse telemetry data
</ParamField>

<ParamField path="LANGFUSE_DEPLOYMENT_VERSION" type="string">
  Deployment version tag for Langfuse traces.

  **Default**: `none` (set in Dockerfile)

  **Purpose**: Track which version of code generated specific traces

  **Note**: Automatically set to git SHA during CI/CD builds
</ParamField>

## System Configuration

<ParamField path="PYTHONPATH" type="string">
  Python module search path.

  **Default**: `/app` (in Docker)

  **Purpose**: Ensure Python can find project modules
</ParamField>

<ParamField path="PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" type="string">
  Protocol Buffers implementation to use.

  **Default**: `python`

  **Purpose**: Use pure Python implementation of Protocol Buffers
</ParamField>

<ParamField path="TRANSFORMERS_NO_ADVISORY_WARNINGS" type="string">
  Disable transformers library warnings.

  **Default**: `1`

  **Purpose**: Suppress warnings about PyTorch (we only use transformers for tokenization)
</ParamField>

## Application Configuration

<ParamField path="free_for_everyone" type="string">
  Enable no-auth mode for Streamlit apps.

  **Default**: `1`

  **Purpose**: Opens Streamlit apps without authentication requirements

  **Used by**: Interactive Streamlit applications
</ParamField>

<ParamField path="runnable_agent_name" type="string">
  Name of the agent to run (used in Docker CMD).

  **Format**: One of the `RunnableAgent` enum values

  **Examples**: `prophet_gpt4o`, `microchain`, `social_media`

  **Purpose**: Specify which agent to run when container starts
</ParamField>

<ParamField path="market_type" type="string">
  Target market type (used in Docker CMD).

  **Options**: `omen`, `manifold`, `polymarket`, `metaculus`

  **Purpose**: Specify which prediction market platform to interact with
</ParamField>

## Example Configuration Files

### Minimal Configuration

Minimum required for basic agent operation:

```bash .env theme={null}
BET_FROM_PRIVATE_KEY=your_private_key_here
OPENAI_API_KEY=sk-your_openai_key_here
```

### Standard Configuration

Recommended for most agents:

```bash .env theme={null}
# Required
BET_FROM_PRIVATE_KEY=your_private_key_here
OPENAI_API_KEY=sk-your_openai_key_here

# Research APIs
SERPER_API_KEY=your_serper_key_here
TAVILY_API_KEY=your_tavily_key_here

# Monitoring
LANGFUSE_SECRET_KEY=sk-lf-your_secret_here
LANGFUSE_PUBLIC_KEY=pk-lf-your_public_here
LANGFUSE_HOST=https://cloud.langfuse.com

# Optional
GRAPH_API_KEY=your_graph_key_here
```

### Full Configuration

Complete configuration with all services:

```bash .env theme={null}
# === Core Credentials ===
BET_FROM_PRIVATE_KEY=your_private_key_here

# === AI Model APIs ===
OPENAI_API_KEY=sk-your_openai_key_here
ANTHROPIC_API_KEY=sk-ant-your_anthropic_key_here
GOOGLE_API_KEY=your_google_key_here
DEEPSEEK_API_KEY=your_deepseek_key_here

# === Research APIs ===
SERPER_API_KEY=your_serper_key_here
TAVILY_API_KEY=tvly-your_tavily_key_here
GRAPH_API_KEY=your_graph_key_here

# === Social Media ===
FARCASTER_PRIVATE_KEY=your_farcaster_key_here
TWITTER_API_KEY=your_twitter_key_here
TWITTER_API_KEY_SECRET=your_twitter_secret_here
TWITTER_ACCESS_TOKEN=your_twitter_token_here
TWITTER_ACCESS_TOKEN_SECRET=your_twitter_token_secret_here
TWITTER_BEARER_TOKEN=your_twitter_bearer_here

# === Vector Database ===
PINECONE_API_KEY=your_pinecone_key_here

# === Database ===
SQLALCHEMY_DB_URL=postgresql://user:password@host:5432/prediction_agent

# === Monitoring ===
LANGFUSE_SECRET_KEY=sk-lf-your_secret_here
LANGFUSE_PUBLIC_KEY=pk-lf-your_public_here
LANGFUSE_HOST=https://cloud.langfuse.com

# === Application ===
free_for_everyone=1
```

## Docker Configuration

### Using .env File

```bash theme={null}
docker run --env-file .env ghcr.io/gnosis/prediction-market-agent:main
```

### Using Environment Variables

```bash theme={null}
docker run \
  -e BET_FROM_PRIVATE_KEY="your_key" \
  -e OPENAI_API_KEY="your_key" \
  -e runnable_agent_name="prophet_gpt4o" \
  -e market_type="omen" \
  ghcr.io/gnosis/prediction-market-agent:main
```

### Docker Compose

```yaml docker-compose.yml theme={null}
version: '3.8'

services:
  agent:
    image: ghcr.io/gnosis/prediction-market-agent:main
    environment:
      - runnable_agent_name=prophet_gpt4o
      - market_type=omen
    env_file:
      - .env
    restart: unless-stopped
```

## Kubernetes Configuration

### Using Secrets

```yaml theme={null}
apiVersion: v1
kind: Secret
metadata:
  name: agent-secrets
  namespace: agents
type: Opaque
stringData:
  BET_FROM_PRIVATE_KEY: "your_private_key"
  OPENAI_API_KEY: "sk-your_openai_key"
  SERPER_API_KEY: "your_serper_key"
  TAVILY_API_KEY: "your_tavily_key"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pma-agent
  namespace: agents
spec:
  template:
    spec:
      containers:
      - name: agent
        image: ghcr.io/gnosis/prediction-market-agent:main
        env:
        - name: runnable_agent_name
          value: "prophet_gpt4o"
        - name: market_type
          value: "omen"
        - name: BET_FROM_PRIVATE_KEY
          valueFrom:
            secretKeyRef:
              name: agent-secrets
              key: BET_FROM_PRIVATE_KEY
        - name: OPENAI_API_KEY
          valueFrom:
            secretKeyRef:
              name: agent-secrets
              key: OPENAI_API_KEY
```

### Using ConfigMap

```yaml theme={null}
apiVersion: v1
kind: ConfigMap
metadata:
  name: agent-config
  namespace: agents
data:
  market_type: "omen"
  free_for_everyone: "1"
  LANGFUSE_HOST: "https://cloud.langfuse.com"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pma-agent
spec:
  template:
    spec:
      containers:
      - name: agent
        envFrom:
        - configMapRef:
            name: agent-config
        - secretRef:
            name: agent-secrets
```

## Agent-Specific Requirements

<AccordionGroup>
  <Accordion title="Prophet Agents">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY` (or alternative AI API key)

    **Optional**:

    * `SERPER_API_KEY` - For web research
    * `TAVILY_API_KEY` - For enhanced research
    * `LANGFUSE_*` - For monitoring
  </Accordion>

  <Accordion title="Microchain Agent">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY`

    **Optional**:

    * `SERPER_API_KEY` - For tool-based research
    * `LANGFUSE_*` - For monitoring
  </Accordion>

  <Accordion title="Social Media Agent">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY`
    * `FARCASTER_PRIVATE_KEY`
    * `TWITTER_API_KEY`
    * `TWITTER_API_KEY_SECRET`
    * `TWITTER_ACCESS_TOKEN`
    * `TWITTER_ACCESS_TOKEN_SECRET`
    * `TWITTER_BEARER_TOKEN`
  </Accordion>

  <Accordion title="Research Agents (Think Thoroughly, GPTR)">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY`
    * `SERPER_API_KEY`
    * `TAVILY_API_KEY`

    **Optional**:

    * `GRAPH_API_KEY` - For blockchain data
    * `LANGFUSE_*` - For monitoring
  </Accordion>

  <Accordion title="NFT Treasury Game Agents">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY`
    * `SQLALCHEMY_DB_URL`

    **Purpose**: Database stores game state and agent interactions
  </Accordion>

  <Accordion title="Embedding-Based Agents (OLAS)">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`
    * `OPENAI_API_KEY`
    * `PINECONE_API_KEY`

    **Purpose**: Vector database for semantic search and retrieval
  </Accordion>

  <Accordion title="Simple Agents (Coinflip, Known Outcome)">
    **Required**:

    * `BET_FROM_PRIVATE_KEY`

    **Note**: These agents don't use AI models or external APIs
  </Accordion>
</AccordionGroup>

## Security Best Practices

<CardGroup cols={2}>
  <Card title="Never Commit Secrets" icon="lock">
    Keep `.env` files in `.gitignore`. Never commit API keys or private keys to version control.
  </Card>

  <Card title="Use Secret Management" icon="key">
    Use proper secret management tools like Google Secret Manager, AWS Secrets Manager, or Kubernetes Secrets.
  </Card>

  <Card title="Rotate Keys Regularly" icon="rotate">
    Rotate API keys and private keys periodically, especially after team member changes.
  </Card>

  <Card title="Limit Permissions" icon="shield-check">
    Use API keys with minimal required permissions. Create separate keys for different environments.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Missing Required Variables">
    When you run an agent, it will check for required variables and tell you if any are missing:

    ```
    Error: Missing required environment variable: OPENAI_API_KEY
    ```

    Add the missing variable to your `.env` file or environment.
  </Accordion>

  <Accordion title="Invalid API Keys">
    If you see authentication errors, verify your API keys:

    ```bash theme={null}
    # Test OpenAI key
    curl https://api.openai.com/v1/models \
      -H "Authorization: Bearer $OPENAI_API_KEY"
    ```
  </Accordion>

  <Accordion title="Database Connection Errors">
    Verify your `SQLALCHEMY_DB_URL` format:

    ```bash theme={null}
    # Correct format
    postgresql://user:password@host:5432/database

    # Common mistakes:
    # - Missing password
    # - Wrong port (default is 5432)
    # - Database doesn't exist
    ```
  </Accordion>

  <Accordion title="Environment Not Loaded">
    Ensure your `.env` file is in the correct location:

    ```bash theme={null}
    # Should be in project root
    ls -la .env

    # Test loading
    python -c "from dotenv import load_dotenv; load_dotenv(); import os; print(os.getenv('OPENAI_API_KEY'))"
    ```
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Local Deployment" icon="laptop-code" href="/deployment/local">
    Run agents locally with environment variables
  </Card>

  <Card title="Docker Deployment" icon="docker" href="/deployment/docker">
    Configure environment for Docker containers
  </Card>

  <Card title="Cloud Deployment" icon="cloud" href="/deployment/cloud">
    Set up secrets and config in Kubernetes
  </Card>

  <Card title="Agent Reference" icon="robot" href="/agents/overview">
    Learn about specific agent requirements
  </Card>
</CardGroup>
