Overview.
Wendesk routes every AI call through src/modules/ai/quota-router.ts. The router decides — per call — whether to use the platform LLM (free quota) or your configured provider key (BYOK). Direct provider SDK calls outside the router are blocked at build time.
All AI usage is logged to the AiUsageQuota table — tokens-in, tokens-out, model, latency, cost, tenantId — for billing and observability.
Free quota.
Each plan includes a monthly token allowance on the platform model:
- Base: 50,000 tokens/mo
- Starter: 250,000 tokens/mo
- Growth: 1,000,000 tokens/mo
- Pro: 5,000,000 tokens/mo
- Enterprise: custom contracted (with cost+20% overage)
BYOK fallback chain.
When your free quota is exhausted, the router applies this priority:
Check tenant quota
If the tenant has free tokens left → use platform Bedrock.
Check BYOK key
Quota exhausted + tenant has a configured BYOK key → use the tenant's key.
Enterprise overage
No BYOK + Enterprise plan → overage at provider cost +20% (post-paid invoice).
Block with upgrade CTA
No BYOK + Starter/Growth/Pro → block with friendly upgrade CTA.
Configure a provider.
Pick the provider you want to bring keys for. All four follow the same flow: get a key from the provider's console → paste into Wendesk Admin → optionally pick a model. Keys are envelope-encrypted with AWS KMS Customer Managed Keys.
Get an API key.
Open the OpenAI dashboard
Go to platform.openai.com/api-keys and sign in.
Create a new secret key
Click "Create new secret key". Name it
wendesk-prod. Give it permission scopeAll(or fine-grained Models & Chat Completions only).Copy the key (sk-...)
It's shown once only. Copy immediately. Format:
sk-proj-XXXXXX...Paste into Wendesk Admin
In Wendesk: Settings → AI & Models → Providers → Add OpenAI. Paste the key, pick default model (
gpt-4o-minirecommended), save.Validate
Wendesk fires a 1-token test call. Green check = ready. Failure = check the key or your OpenAI billing status.
gpt-4o-mini for general drafts (fast, cheap), gpt-4.1 for complex reasoning (slower, smarter), gpt-4o when you need vision or audio.
# Quick test — list available models
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer sk-proj-XXXX..." \
| jq '.data[] | .id' | head
# Or — fire a one-token test
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer sk-proj-XXXX..." \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}],"max_tokens":1}'Get an API key.
Open the Anthropic console
Go to console.anthropic.com/settings/keys and sign in.
Create a new key
Click "Create Key". Name it
wendesk-prod. Choose your workspace.Copy the key (sk-ant-...)
Format:
sk-ant-api03-XXXX.... Shown once — copy now.Paste into Wendesk Admin
Settings → AI & Models → Providers → Add Anthropic. Default model
claude-haiku-4-5-20251001for cheap drafts,claude-sonnet-4-6for production reasoning.
Haiku 4.5 — fastest, cheapest, great for tagging/classification. Sonnet 4.6 — sweet spot for most reasoning. Opus 4.7 — when you need the absolute best.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: sk-ant-api03-XXXX..." \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-haiku-4-5-20251001",
"max_tokens": 50,
"messages": [{"role":"user","content":"Reply with just OK"}]
}'Get an API key.
Open Google AI Studio
Go to aistudio.google.com/apikey and sign in with your Google account.
Create API key
Click "Create API key". Pick a Google Cloud project (or let Google auto-create one).
Copy the key (AIza...)
Format:
AIzaSyXXXXXX...Paste into Wendesk Admin
Settings → AI & Models → Providers → Add Gemini. Default model
gemini-2.0-flash(1M context, fast);gemini-2.0-profor hardest tasks.
Free Gemini API tier has rate limits (15 req/min for flash). For production traffic, enable billing on the Google Cloud project — it switches to pay-as-you-go automatically.
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=AIzaSyXXXX..." \
-H "Content-Type: application/json" \
-d '{ "contents": [{ "parts": [{ "text": "Reply with just OK" }] }] }'Configure IAM credentials.
Enable Bedrock in your AWS region
In AWS Console: Bedrock → Model access → Manage. Request access to the models you want (Anthropic Claude family is the most common). Approval is usually instant.
Create an IAM user with Bedrock policy
IAM → Users → Add user. Attach the managed policy
AmazonBedrockFullAccess(or scoped custom policy withbedrock:InvokeModelonly).Generate access keys
For the new user, create programmatic access keys:
AKIA...+ secret. Regionap-south-1is the Wendesk default.Paste into Wendesk Admin
Settings → AI & Models → Providers → Add Bedrock. Three fields: Access Key ID, Secret Access Key, Region. Default model
anthropic.claude-haiku-4-5via Bedrock.
Best for compliance. Your data never leaves AWS. India-region (Mumbai, ap-south-1) hosting available — keeps DPDP and HIPAA-aligned customers happy.
# Configure AWS CLI aws configure # Enter Access Key, Secret, region (ap-south-1) # Test Bedrock model access aws bedrock list-foundation-models \ --region ap-south-1 \ --query "modelSummaries[?contains(modelId,'claude')].modelId"
Security & logging.
Every BYOK key is encrypted at rest with AES-256-GCM envelope encryption using an AWS KMS-managed Customer Managed Key (CMK). On Pro+ plans, keys live in the tenant's dedicated database (separate logical DB per tenant). Never logged. Never returned by any API endpoint. Decrypted only at request time inside our trust boundary.
All AI calls are logged to AiUsageQuota: tokens-in, tokens-out, model, latency, cost, tenantId. Used for quota enforcement and billing. Healthcare tenants (industry = healthcare): PHI is auto-redacted at the call site BEFORE sending to the provider. Redaction events are logged.
Wendesk requests no data retention from OpenAI (via X-OpenAI-Skip-Training: true), no training from Anthropic, and uses Gemini/Bedrock in stateless mode by default. Your tenant data is never used to train provider models.
Troubleshooting.
- "Invalid API key" → key was revoked, expired, or you copy-pasted a typo. Re-copy from provider console.
- "Insufficient quota" on OpenAI → you have a key but no billing set up; add a card at platform.openai.com/account/billing.
- "Model not found" → model ID changed (provider-side); update the default model under Wendesk Settings.
- "Rate limit exceeded" → you hit your provider's per-minute/hour limit; upgrade your tier or use a different provider for the burst.
- Bedrock "AccessDeniedException" → IAM policy missing
bedrock:InvokeModel, or you didn't request model access in the AWS console.
Email [email protected] with the trace ID from the error toast. We resolve provider issues inside one business day.