Authentication
Every request to the Masar API requires an API key. Keys are scoped to your organization and carry usage limits based on your plan.
Create an API Key
- Sign in at masar.almadar.io
- Navigate to Settings > API Keys
- Click Create Key, give it a name (e.g., "dev-agent"), and copy the value
- Store it securely. The full key is shown only once.
Set the Environment Variable
The SDKs read from MASAR_API_KEY by default:
export MASAR_API_KEY="msk_live_abc123..."
Add this to your .bashrc, .zshrc, or .env file so it persists across sessions.
Using the Key in Code
The SDK picks up the environment variable automatically:
from masar import MasarClient
# Reads MASAR_API_KEY from environment
client = MasarClient()
# Or pass it explicitly
client = MasarClient(api_key="msk_live_abc123...")
Key Prefixes
| Prefix | Environment | Rate Limit |
|---|---|---|
msk_live_ | Production | Based on plan |
msk_test_ | Sandbox | 100 requests/minute |
Test keys work against the same models but responses are not stored in your organization's memory.
Security Best Practices
- Never commit API keys to version control
- Use environment variables or a secrets manager in production
- Rotate keys periodically from the dashboard
- Use separate keys for development and production
Revoking a Key
Go to Settings > API Keys, find the key, and click Revoke. The key stops working immediately. Active requests in flight may still complete.
Next Steps
- Quickstart - Make your first API call
- Agent Integration - Wire Masar into your LLM agent