Rawi (راوي) Documentation | Environment Variables
Configuring Environment Variables for Rawi CLI
Section titled “Configuring Environment Variables for Rawi CLI”Rawi CLI supports environment variables for configuration, similar to the AWS CLI. Environment variables provide a convenient way to set credentials, provider options, and other settings for scripting, automation, or temporary overrides.
Precedence of Options
Section titled “Precedence of Options”Rawi CLI loads configuration in the following order (highest to lowest):
- Command-line options (e.g.
--profile
,--provider
,--api-key
) - Environment variables (see below)
- Profile settings in
~/.rawi/credentials
(default or named profile, stored as JSON)
If you set a value in multiple places, the command-line option takes precedence over environment variables, which take precedence over profile settings.
How to Set Environment Variables
Section titled “How to Set Environment Variables”-
Set environment variables in your shell:
Terminal window export RAWI_PROFILE=workexport RAWI_PROVIDER=openaiexport RAWI_API_KEY=sk-your-keyexport RAWI_MODEL=gpt-4oexport RAWI_BASE_URL=https://api.openai.com/v1export RAWI_TEMPERATURE=0.7export RAWI_MAX_TOKENS=2048export RAWI_LANGUAGE=english
-
Set environment variables in Command Prompt:
Terminal window set RAWI_PROFILE=workset RAWI_PROVIDER=openaiset RAWI_API_KEY=sk-your-keyset RAWI_MODEL=gpt-4oset RAWI_BASE_URL=https://api.openai.com/v1set RAWI_TEMPERATURE=0.7set RAWI_MAX_TOKENS=2048set RAWI_LANGUAGE=english
-
Set environment variables in PowerShell:
Terminal window $env:RAWI_PROFILE="work"$env:RAWI_PROVIDER="openai"$env:RAWI_API_KEY="sk-your-key"$env:RAWI_MODEL="gpt-4o"$env:RAWI_BASE_URL="https://api.openai.com/v1"$env:RAWI_TEMPERATURE="0.7"$env:RAWI_MAX_TOKENS="2048"$env:RAWI_LANGUAGE="english"
Supported Environment Variables
Section titled “Supported Environment Variables”Variable | Description | Example Value |
---|---|---|
RAWI_PROFILE | Profile name to use | work |
RAWI_PROVIDER | AI provider (openai , anthropic , etc.) | openai |
RAWI_API_KEY | API key for the provider | sk-... |
RAWI_MODEL | Model name | gpt-4o |
RAWI_BASE_URL | Custom base URL for provider API | https://api.openai.com/v1 |
RAWI_TEMPERATURE | Sampling temperature (0-2) | 0.7 |
RAWI_MAX_TOKENS | Maximum tokens for response | 2048 |
RAWI_LANGUAGE | Language setting (english , arabic ) | english |
RAWI_REGION | Region (for Bedrock/AWS providers) | us-east-1 |
RAWI_ACCESS_KEY_ID | AWS access key (for Bedrock) | AKIA... |
RAWI_SECRET_ACCESS_KEY | AWS secret key (for Bedrock) | wJalr... |
RAWI_SESSION_TOKEN | AWS session token (for Bedrock, optional) | FwoGZXIvYXdz... |
RAWI_USE_PROVIDER_CHAIN | Use AWS provider chain (for Bedrock) | true |
RAWI_RESOURCE_NAME | Azure resource name (for Azure provider) | my-azure-resource |
RAWI_API_VERSION | Azure API version | 2024-10-01-preview |
Note: Not all variables are required for every provider. See the Configuration Guide and Providers Guide for details.
Example: Using Environment Variables
Section titled “Example: Using Environment Variables”export RAWI_PROFILE=workexport RAWI_PROVIDER=bedrockexport RAWI_REGION=us-west-2export RAWI_USE_PROVIDER_CHAIN=true
rawi ask "Summarize this S3 bucket policy"
This will use the work
profile, Amazon Bedrock provider, and the AWS credential provider chain for authentication.
Making Environment Variables Persistent
Section titled “Making Environment Variables Persistent”To make environment variables available in every terminal session, add the export
lines to your shell’s startup file (e.g. ~/.bashrc
, ~/.zshrc
).
Overriding with Command-Line Options
Section titled “Overriding with Command-Line Options”You can always override environment variables by specifying options directly:
rawi ask "What is TypeScript?" --profile personal --provider openai --model gpt-4o
Troubleshooting
Section titled “Troubleshooting”- If a required variable is missing, Rawi will prompt for configuration or show an error.
- To view the current configuration, run:
rawi configure --show