API Reference

Base URL: https://llm-service-438759468271.europe-north1.run.app  ·  All streaming endpoints return SSE.

// AUTH

POST/auth/registerNO AUTH

Creates an API key and grants 50 000 free tokens. No authentication required.

Body{"email": "...", "name": "..."}
Returns{"key": "mmk_...", "tokens": 50000, "message": "..."}
curl -X POST https://llm-service-438759468271.europe-north1.run.app/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "name": "Your Name"}'
GET/auth/meBEARER

Returns account info. Accepts Firebase ID token or an mmk_ API key.

Returns{"auth_type": "...", "email": "...", "tokens": 0, "is_admin": false}
curl https://llm-service-438759468271.europe-north1.run.app/auth/me \
  -H "Authorization: Bearer $MMK_API_KEY"
POST/auth/link-keyFIREBASE BEARER

Links an API key to a Firebase account and merges token balances.

Body{"api_key": "mmk_..."}
curl -X POST https://llm-service-438759468271.europe-north1.run.app/auth/link-key \
  -H "Authorization: Bearer $FIREBASE_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"api_key": "mmk_..."}'

// BILLING

GET/billing/packagesNO AUTH

Returns the list of available token packages.

curl https://llm-service-438759468271.europe-north1.run.app/billing/packages
POST/billing/checkoutBEARER

Initiates a Stripe checkout session. Redirect the user to checkout_url.

Body{"package_id": "..."}
Returns{"checkout_url": "https://checkout.stripe.com/..."}
curl -X POST https://llm-service-438759468271.europe-north1.run.app/billing/checkout \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"package_id": "tokens_100k"}'

// FILE MANAGEMENT

POST/api/v1/uploadBEARER

Uploads a file into the session context (multipart form, field name file).

Returns{"filename": "report.pdf"}
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/upload \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -F "file=@report.pdf"
GET/filesBEARER

Lists all files currently in the session context.

curl https://llm-service-438759468271.europe-north1.run.app/files \
  -H "Authorization: Bearer $MMK_API_KEY"
GET/file/{filename}BEARER

Returns file content or triggers a download.

curl https://llm-service-438759468271.europe-north1.run.app/file/report.pdf \
  -H "Authorization: Bearer $MMK_API_KEY" \
  --output report.pdf
DELETE/file/{filename}BEARER

Deletes a file from the session context.

curl -X DELETE https://llm-service-438759468271.europe-north1.run.app/file/report.pdf \
  -H "Authorization: Bearer $MMK_API_KEY"

// CHAT & ANALYSIS TOOLS

All endpoints below stream SSE. Each data: line is a progress update. [TOOL_RESULT] {} contains the structured JSON result. [DONE] ends the stream.

# Consume an SSE stream with curl
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/asset-research \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Analyse AAPL and MSFT"}' \
  --no-buffer

# Each line looks like:
# data: Fetching market data for AAPL...
# data: [TOOL_RESULT] {"aapl": {...}, "msft": {...}}
# data: [DONE]
POST/api/v1/chatBEARER · SSE

General LLM chat with file context. Optionally pass function_list to enable specific tools.

Body{"user_input": "...", "function_list": ["accounting_tool"]}
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/chat \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Summarise the uploaded PDF"}' \
  --no-buffer
POST/api/v1/researchBEARER · SSE

Deep iterative research with grounded web search. Returns a structured research report.

curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/research \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Research the impact of AI on labour markets"}' \
  --no-buffer
POST/api/v1/asset-researchBEARER · SSE

Fundamental analysis for one or more tickers. Fetches market data, runs DCF, and aggregates news sentiment. Returns per-asset metrics and a comparison.

curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/asset-research \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Analyse AAPL and MSFT"}' \
  --no-buffer
POST/api/v1/portfolio-riskBEARER · SSE

Portfolio risk analysis. Accepts tickers in the message or via an uploaded CSV. Returns VaR, CVaR, Sharpe ratio, beta, and correlation matrix.

curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/portfolio-risk \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Risk analysis for AAPL 40%, MSFT 30%, GOOGL 30%"}' \
  --no-buffer
POST/api/v1/accountingBEARER · SSE

Double-entry bookkeeping from a bank statement PDF. Returns a CSV ledger and saves accounting.xlsx to the session.

# 1. Upload the bank statement
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/upload \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -F "file=@statement.pdf"

# 2. Run accounting
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/accounting \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Process the uploaded bank statement"}' \
  --no-buffer
POST/api/v1/ikbr-reportBEARER · SSE

Parses an uploaded IBKR activity statement CSV. Returns trade metrics, open positions, and a Finnish tax report. Saves an Excel report to the session.

# 1. Upload the IBKR CSV
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/upload \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -F "file=@ibkr_activity.csv"

# 2. Generate report
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/ikbr-report \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Generate IBKR report for 2024"}' \
  --no-buffer
POST/api/v1/macro-situationBEARER · SSE

Global market situation report: events in the last 24 h, equity indices, bond yields, currencies, and commodities for Americas, Europe, Africa, and Asia-Pacific. Returns structured JSON.

curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/macro-situation \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Global macro snapshot"}' \
  --no-buffer