Skip to main content

Environment file setup

The project uses environment variables for configuration. Create a .env file in the root directory of the repository.
1

Create .env file

In the root of the repository, create a new file named .env:
touch .env
2

Add required variables

At minimum, add these two required variables:
.env
BET_FROM_PRIVATE_KEY=your_private_key_here
OPENAI_API_KEY=your_openai_api_key_here
Never commit your .env file to version control. It should already be in .gitignore.
3

Add optional variables

Depending on which agents you want to run, you may need additional variables. The agent will inform you if any are missing when you try to run it.

Required variables

These variables are required for basic agent functionality:
BET_FROM_PRIVATE_KEY
string
required
Private key for the Ethereum wallet that will place bets on prediction markets.
Keep this key secure! It controls access to your funds on-chain. Use a dedicated wallet for testing with small amounts.
How to get it:
  • Export from MetaMask or another wallet
  • Generate a new wallet using web3 libraries
  • Use a test wallet for development
OPENAI_API_KEY
string
required
API key for OpenAI services, used by agents that leverage GPT models for reasoning and predictions.How to get it:
  1. Sign up at platform.openai.com
  2. Navigate to API keys section
  3. Create a new secret key
  4. Copy and save it securely

Optional API keys

These variables enable additional functionality:

Web search and research

SERPER_API_KEY
string
API key for Serper, which provides Google Search results for agent research.Used by: Research agents, think thoroughly agentsGet it at: serper.dev
TAVILY_API_KEY
string
API key for Tavily, a search API optimized for AI agents and LLMs.Used by: Research agents, web scraping agentsGet it at: tavily.com

Blockchain and data

GRAPH_API_KEY
string
API key for The Graph, used to query blockchain data from subgraphs.Used by: Omen agents, market data fetchingGet it at: thegraph.com

Social media integration

FARCASTER_PRIVATE_KEY
string
Private key for Farcaster account integration.Used by: Social media agents
TWITTER_ACCESS_TOKEN
string
Twitter OAuth access token for posting and reading tweets.Used by: Social media agents
TWITTER_ACCESS_TOKEN_SECRET
string
Twitter OAuth access token secret.Used by: Social media agents
TWITTER_BEARER_TOKEN
string
Twitter API v2 bearer token for authentication.Used by: Social media agents
TWITTER_API_KEY
string
Twitter API consumer key.Used by: Social media agents
TWITTER_API_KEY_SECRET
string
Twitter API consumer secret.Used by: Social media agentsGet Twitter credentials at: developer.twitter.com

Monitoring and observability

LANGFUSE_SECRET_KEY
string
Secret key for Langfuse, an LLM engineering platform for tracing and monitoring.Used by: Agent monitoring, debugging
LANGFUSE_PUBLIC_KEY
string
Public key for Langfuse.Used by: Agent monitoring, debugging
LANGFUSE_HOST
string
Langfuse host URL (defaults to cloud instance if not specified).Used by: Agent monitoring, debuggingGet Langfuse credentials at: langfuse.com

Vector database

PINECONE_API_KEY
string
API key for Pinecone vector database, used for semantic search and memory.Used by: Long-term memory agents, embedding agentsGet it at: pinecone.io

Database

SQLALCHEMY_DB_URL
string
Database connection URL for SQLAlchemy (e.g., PostgreSQL, SQLite).Format: postgresql://user:password@host:port/databaseUsed by: Data persistence, agent state management

Development mode

free_for_everyone
string
default:"0"
Set to 1 to open Streamlit apps in no-auth mode for development.
free_for_everyone=1
Only use this in development environments, not in production.

Complete .env.example

Here’s the complete .env.example file from the repository:
.env.example
OPENAI_API_KEY=
SERPER_API_KEY=
TAVILY_API_KEY=
BET_FROM_PRIVATE_KEY=
GRAPH_API_KEY=
LANGFUSE_SECRET_KEY=
LANGFUSE_PUBLIC_KEY=
LANGFUSE_HOST=
FARCASTER_PRIVATE_KEY=
PINECONE_API_KEY=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_BEARER_TOKEN=
TWITTER_API_KEY=
TWITTER_API_KEY_SECRET=
SQLALCHEMY_DB_URL=
# Opens streamlit in no-auth mode
free_for_everyone=1

Configuration by agent type

Different agents require different configurations:
Required for: coinflip, knownoutcome
BET_FROM_PRIVATE_KEY=your_private_key
OPENAI_API_KEY=your_openai_key

Verifying configuration

When you run an agent, it will automatically check for required environment variables:
python prediction_market_agent/run_agent.py coinflip omen
If any required variables are missing, you’ll see an error message indicating which ones need to be set.
The agent will only check for variables it actually needs, so you don’t need to configure everything upfront.

Security best practices

Use test wallets

For development, use dedicated test wallets with small amounts of funds

Never commit secrets

Ensure .env is in .gitignore and never commit API keys or private keys

Rotate keys regularly

Regularly rotate API keys and private keys, especially after development

Use environment separation

Keep separate .env files for development, staging, and production

Next steps

Quickstart

Run your first agent with the coinflip example

Create custom agents

Build your own prediction market agent

Build docs developers (and LLMs) love