PyRIT loads API credentials from environment variables or .env files. This page shows how to set up your .env file with credentials for your AI provider.
Creating Your .env File¶
Create the PyRIT config directory and copy the example file:
mkdir -p ~/.pyrit
cp .env_example ~/.pyrit/.envEdit
~/.pyrit/.envand fill in the credentials for your provider:
OPENAI_CHAT_ENDPOINT="https://api.openai.com/v1"
OPENAI_CHAT_KEY="sk-your-key-here"
OPENAI_CHAT_MODEL="gpt-4o"Get your API key from platform
OPENAI_CHAT_ENDPOINT="https://your-resource.openai.azure.com/openai/v1"
OPENAI_CHAT_KEY="your-azure-key-here"
OPENAI_CHAT_MODEL="your-deployment-name"Find these values in Azure Portal: Azure AI Services > Azure OpenAI > Your Resource > Keys and Endpoint.
OPENAI_CHAT_ENDPOINT="http://127.0.0.1:11434/v1"
OPENAI_CHAT_KEY="not-needed"
OPENAI_CHAT_MODEL="llama2"Requires Ollama running locally. No API key needed.
OPENAI_CHAT_ENDPOINT="https://api.groq.com/openai/v1"
OPENAI_CHAT_KEY="gsk_your-key-here"
OPENAI_CHAT_MODEL="llama3-8b-8192"Get your API key from console.groq.com.
OPENAI_CHAT_ENDPOINT="https://openrouter.ai/api/v1"
OPENAI_CHAT_KEY="sk-or-v1-your-key-here"
OPENAI_CHAT_MODEL="anthropic/claude-3.7-sonnet"Get your API key from openrouter.ai.
What’s in .env_example?¶
The .env_example file in the repository root contains entries for all supported targets — OpenAI chat, responses, realtime, image, TTS, video, Azure ML, embeddings, content safety, and more. Most users only need the three OPENAI_CHAT_* variables above. Fill in additional sections only as you need them.
What’s Next?¶
Configuration File (.pyrit_conf) — Set up the full configuration with initializers, database, and environment file management
User Guide — Start using PyRIT