BYOK API KEY
🌌 Astrosinyal · AMI Docs
BYOK GUIDE
Bring Your Own Key (BYOK): Groq & OpenRouter
1. What BYOK is and when you need it
AMI can use a Large Language Model (LLM) to write the AI reasoning section of your signals and to answer Telegram bot commands. That call needs an API key.
| Plan | LLM source |
|---|---|
| Free | No pooled server key → AI reasoning stays in template mode unless you add your own key |
| Standard (Rp99.000 / $7 /30 days) | Server pooled key included — BYOK optional |
Resolution order (automatic): your key → server pooled key → built-in template mode (no external call). If you save a key, it always wins.
Privacy & storage: keys are stored per-tenant,
encrypted at rest (Fernet authenticated encryption) and never shown in
full — only a mask. With your key active, the data sent for AI reasoning
(symbol, OHLCV-derived features, Vedic context, scores) goes only to the provider
you choose, under that provider’s privacy policy. Replace or delete keys anytime;
changes apply on the next AI call.
2. Which provider should you pick?
| Groq | OpenRouter | |
|---|---|---|
| Cost | Free tier (rate-limited) | Pay-as-you-go credits;
many :free models |
| Strength | Extremely fast inference | One key → hundreds of models |
| AMI default model | llama-3.3-70b-versatile |
openai/gpt-4o-mini (small credit needed) |
| Key format | gsk_... | sk-or-v1-... |
| Best for | $0 cost, testing BYOK | Model choice or premium models |
Both work identically in AMI — only one key is active at a time.
3. Part A — Get a Groq API key (≈2 minutes)
- Open console.groq.com and sign in (Google or GitHub).
- In the left sidebar open API Keys.
- Click Create API Key, name it something you will recognize later
(e.g.
ami-byok), then Create. - Copy the key immediately — it starts with
gsk_and is shown only once. Save it in a password manager. Lost it? Create another key and revoke the old one. - (Optional) The Models page lists the AMI default
llama-3.3-70b-versatileand other free models. - (Optional) The Usage page shows your daily request consumption.
Groq’s free tier has per-day rate limits. If you hit
HTTP 429, wait for the limit window to reset — it is not a broken key.
4. Part B — Get an OpenRouter API key (≈3 minutes)
- Open openrouter.ai and sign in (GitHub or Google).
- Go to Credits and add credit (card/PayPal) — needed for paid models
such as the default
openai/gpt-4o-mini.
Free alternative: browse the Models page and pick any model ending in:free(e.g.meta-llama/llama-3.3-70b-instruct:free) — no credit required; you type that name into the Model field later. - Open Keys → Create Key.
- Optionally set a name (
ami-byok) or a monthly spend limit, then create. - Copy the key immediately — it starts with
sk-or-v1-and is shown only once. Save it in a password manager. - (Optional) The Activity page tracks spend per key.
5. Connect the key to AMI (≈30 seconds)
- Log in to the portal: ami.astrosinyal.com/portal
- Open Integrations (๐ Integrations โ BYOK).
- Fill in:
- Provider →
groqoropenrouter(must match where you created the key). - API key → paste your
gsk_...orsk-or-v1-.... - Model (optional) → leave empty for the provider default, or type another model name.
- Provider →
- Click ๐พ Save LLM key.
- Click ๐งช Test — a green confirmation means the key works end-to-end; any red error is explained in section7.
- Verify in practice: run an analysis — the AI reasoning block should now contain a written explanation instead of the built-in template text.
Change later: paste a new key and Save (applies on
the next AI call). To remove: ๐ Remove → AMI falls back to
pooled/template mode.
6. Model field reference
- Accepted format: letters, digits, and
- _ . : /(1–100 chars). Examples:llama-3.3-70b-versatile,openai/gpt-4o-mini,meta-llama/llama-3.3-70b-instruct:free. - Wrong format →
Invalid model name (1-100 chars: letters, digits, - _ . : /). - Wrong provider →
Invalid provider - choose groq or openrouter. - Leave it empty if unsure — AMI uses the tested provider default.
7. Troubleshooting
| Symptom / error | Cause | Fix |
|---|---|---|
Invalid provider - choose groq or openrouter. |
Dropdown does not match the key | Pick the provider where the key was created |
Invalid model name (...) | Illegal chars or too long | Only - _ . : / allowed; or leave empty |
| HTTP 401 / 403 from Test | Wrong, truncated, or revoked key | Re-copy from the provider dashboard and Save again |
| HTTP 429 | Provider rate limit (common on Groq free tier) | Wait for the window to reset, or switch model |
| HTTP 402 / insufficient credit | OpenRouter paid model without credit | Add credit, or use a :free model name |
| Model not found (HTTP 400) | Typo in Model field | Leave Model empty or copy the exact model ID from the provider’s model list |
| AI reasoning still template after saving | Key not saved or Test failed | Check the green/red message under the buttons; Save again |
| Key exposed somewhere by mistake | — | Revoke it at the provider, create a new one, Save it in AMI |
8. Security checklist
- ✅ Treat API keys like passwords — never post them in chats, charts, or repos.
- ✅ AMI shows only a mask after saving; the full key cannot be re-displayed.
- ✅ Keys are encrypted at rest per tenant and used only for calls to the provider you selected.
- ✅ Rotate freely: revoke at the provider, paste the new key, Save.
- ✅ Spend limits (OpenRouter) are a good extra guard on shared machines.
AMI provides tools and calibrated probability, never certainty
(model AUC ≈ 0.53) · Not financial advice · BYOK keys and their
usage are governed by each provider’s own terms and privacy policy.