إنتقل إلى المحتوى الرئيسي

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

  1. Sign in at masar.almadar.io
  2. Navigate to Settings > API Keys
  3. Click Create Key, give it a name (e.g., "dev-agent"), and copy the value
  4. 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

PrefixEnvironmentRate Limit
msk_live_ProductionBased on plan
msk_test_Sandbox100 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