ORRANGE / Developer
AI Provider
Hamster is an LLM invoked through a single, swappable OpenAI-compatible seam. The API key is server-only.
Inference runs off-chain: the app calls an OpenAI-compatible /chat/completions endpoint from the server. It is not part of the Starknet transaction path and never signs anything.
The provider flow
UI (/treasury)
│
▼
POST /api/ai/analyze
│
▼
provider.ts (createDefaultProvider)
│
▼
OpenAI-compatible /chat/completions
│
▼
structured JSON proposal
│
▼
schema validation (validateProposal)
│
▼
deterministic policy verdictConfiguration
| Variable | Purpose | Default |
|---|---|---|
AI_API_KEY | Bearer token for the endpoint | server-only |
AI_BASE_URL | Base URL of the endpoint | https://api.openai.com/v1 |
AI_MODEL | Model identifier | gpt-4o-mini |
AI_API_KEY must never be exposed to the browser. It is read on the server in src/ai/provider.ts. Prefixing it with NEXT_PUBLIC_ would ship the key into the client bundle — never do that.Compatible endpoints
The provider speaks the OpenAI chat-completions JSON format with strict JSON output (response_format.json_object). Any compatible service works — the implementation is not locked to one vendor:
- OpenAI
- OpenRouter / Together / Groq
- A local llama.cpp / vLLM server
- Any OpenAI-compatible gateway used for the demo
Example — point at OpenAI:
AI_BASE_URL=https://api.openai.com/v1
AI_MODEL=gpt-4o-miniExample — any OpenAI-compatible gateway:
AI_BASE_URL=https://your-gateway.example/v1
AI_MODEL=your-model-idRunning without the AI
If no AI is configured, /treasury still works: portfolio, health, and the proactive diagnosis use the deterministic engine. Only the LLM-backed diagnosis and recommendation are unavailable.
