--- title: NegOptim AI Service emoji: 🤖 colorFrom: green colorTo: blue sdk: docker app_port: 7860 pinned: false --- # NegOptim AI Service Stateless FastAPI backend for the `negOptimChatExternal` Salesforce LWC. It wraps Groq and OpenRouter LLMs with a schema-grounded NegOptim catalog, an embedding router, three Salesforce tools (executed by Apex, not here), a per-query usage report and a canned-response cache for small talk. ## Endpoints - `GET /health` — liveness, active models, router mode - `GET /models` — selectable models (Groq + OpenRouter) - `GET /usage?model=` — daily usage for the selected model - `POST /chat` — one agent step (final answer or tool calls for Salesforce) ## Configuration (Space secrets → Settings → Variables and secrets) - `OPENROUTER_API_KEY` — required for OpenRouter models - `GROQ_API_KEY` — required for Groq models (preferred) - `SERVICE_API_KEY` — shared secret; must match the Salesforce custom setting - `OPENROUTER_MODEL` / `GROQ_MODEL` — optional primary-model overrides No Salesforce credentials live here — the org calls this service via a Named Credential, and the LLM's tool requests are executed inside Salesforce.