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="openai/gpt-oss-20b"Get your API key from console.groq.com.
OPENAI_CHAT_ENDPOINT="https://router.huggingface.co/v1"
OPENAI_CHAT_KEY="hf_your-token-here"
OPENAI_CHAT_MODEL="meta-llama/Llama-3.1-8B-Instruct"Get your token from huggingface
OPENAI_CHAT_ENDPOINT="https://api.anthropic.com/v1"
OPENAI_CHAT_KEY="sk-ant-your-key-here"
OPENAI_CHAT_MODEL="claude-opus-5-5"Get your API key from console
OPENAI_CHAT_ENDPOINT="https://generativelanguage.googleapis.com/v1beta/openai"
OPENAI_CHAT_KEY="your-gemini-key-here"
OPENAI_CHAT_MODEL="gemini-3.8-flash"Get your API key from Google AI Studio. Uses the Gemini API’s OpenAI compatibility endpoint.
OPENAI_CHAT_ENDPOINT="https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1"
OPENAI_CHAT_KEY="your-bedrock-api-key-here"
OPENAI_CHAT_MODEL="openai.gpt-oss-120b-1:0"Create an Amazon Bedrock API key in the AWS console and adjust the region in the endpoint as needed. Bedrock’s Chat Completions API serves only the models that support it (e.g., the OpenAI open-weight models); other Bedrock models use different APIs.
OPENAI_CHAT_ENDPOINT="https://openrouter.ai/api/v1"
OPENAI_CHAT_KEY="sk-or-v1-your-key-here"
OPENAI_CHAT_MODEL="anthropic/claude-sonnet-5"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
Framework — Start using PyRIT