API keys for developers
An API key lets you get SafeLaw answers in your own application. A live key spends money from the account wallet; a test key spends nothing.
Create a key
- Open “Settings” → “API”.
- In the “New key” section, enter a “Name” and choose a “Mode” («Режим»): “Live” or “Test”.
- Click “Create”.
- In the “Key created” window, click “Copy” or “Download as file” and store the key in a safe place.
- Click “Done, I saved it”. Until you refresh the page, the key is still available in the bar at the top: “The key is still available to copy until you refresh the page.” («Ключ ещё доступен для копирования — до обновления страницы.»)
Modes
| Mode | Key prefix | What it spends |
|---|---|---|
| Live | sf_live_… | wallet balance: $2 per 1M input tokens, $4 per 1M output tokens, charged in UZS |
| Test | sf_test_… | nothing: answers with a simplified model, for testing the integration |
Manage keys in the “My keys” section:
- “Copy”: copy the key value;
- “Settings”: the name and “Monthly cap, tokens” (“0 means no cap” («0 — без предела»)). The cap protects you from a script that uses up the entire balance overnight;
- “Regenerate”: a new key with the same balance and settings; the old one stops working immediately;
- “Revoke”: requests with the key stop working immediately.
The “Monitoring” section shows requests, spending and errors for 7, 30 or 90 days. All live keys spend the shared “Wallet” balance. To top up the wallet, write to support.
Only the owner creates organization keys: “Organization” → “Settings” → “API keys” («API-ключи»).
If it doesn't work
| What you see | What to do |
|---|---|
| “API is not yet available for your account.” («API пока недоступен для вашего аккаунта.») | Write to SafeLaw support. |
| “A live key uses paid tokens. A new key is created with a zero balance, so buy tokens first.” («Рабочий ключ расходует оплаченные токены. Новый ключ создаётся с нулевым балансом — сначала купите токены.») | Top up the wallet, then use the live key. For testing, use a test key. |
| “This key's value can't be displayed. Regenerate the key to get a new one.” («Значение этого ключа недоступно для показа — перевыпустите ключ, чтобы получить новое.») | Click “Regenerate” and replace the key in your application. |
| “Only the organization manager can manage API keys.” | Organization keys are created by the owner. |
| “The key was not found or is already revoked.” | Create a new key. |
Related articles
Was this article helpful?
Thanks! Glad it helped.
Sorry about that. Write to us on Telegram or at support@safelaw.ai — we’ll help and improve the article.