API & Docs

Base URL: https://llm-service-438759468271.europe-north1.run.app

// What is this

This is a set of AI tools I've built that I use personally and have made available as an API. The tools cover things like asset research, portfolio risk analysis, accounting, global macro situation reports, quarterly earnings comparisons, and document translation. They can be used through the chat interface in the browser, or programmatically via the REST API documented below. I develop existing ones and release new ones at an irregular pace. Use at your own risk, I give no guarantees on the results. If you purchased tokens and got garbage results please email me the details and I can give a refund.

All endpoints that produce substantial output stream their results as Server-Sent Events (SSE). Each data: line is a progress update or result chunk. A data: [TOOL_RESULT] {} line contains the structured JSON result. The stream ends with data: [DONE].

# Example: stream a tool result 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 PATH"}' \
  --no-buffer

# data: Fetching market data for PATH...
# data: Running DCF analysis...
# data: [TOOL_RESULT] {"path": {"price": 11.72, ...}}
# data: [DONE]

// Getting started

There are two ways to get access — the chat interface (no coding required) or the API. Both use the same token balance.

Option A — Chat interface

  • Go to mmkki.com/chat
  • Sign in with Google — you get 50,000 free tokens automatically
  • Select a tool from the menu, upload files if needed, and send your prompt
  • Buy more tokens at mmkki.com/account if you run out

Option B — API key

  • Register for an API key with POST /auth/register (see Auth section below)
  • You receive an mmk_… key and 50,000 free tokens
  • Pass the key as Authorization: Bearer mmk_… on every request
  • Buy more tokens via POST /billing/checkout or at mmkki.com/account

If you already have both a Firebase (Google sign-in) account and an API key, use POST /auth/link-key to merge the balances into one account.

// Tokens & pricing

Every request consumes tokens proportional to the amount of LLM work performed. Tool endpoints apply a cost multiplier on top of the raw LLM token count to account for grounded web search calls and other external API costs.

PackageTokensPrice
Starter100,000$2
Standard500,000$8
Pro2,000,000$25

Cost multipliers by tool — billed tokens = raw LLM tokens × multiplier:

Chat / research1.0 – 2.5×
Asset research2.0×
Deep asset research3.0×
Macro situation2.5×
Portfolio risk1.5×
Accounting / IBKR report1.2×
Quarterly comparison2.0×
Translation1.5×

// 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 and current token balance. Accepts either a 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 existing API key to a Firebase (Google) account and merges the token balances. Use this if you registered an API key separately and later signed in with Google.

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

Payments are handled by Stripe. The checkout flow redirects to a Stripe-hosted page — no card data touches the API server. Tokens are credited instantly after payment.

GET/billing/packagesNO AUTH

Returns the available token packages with prices.

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

Creates a Stripe checkout session. Redirect the user to the returned checkout_url. Tokens are credited automatically via webhook after payment.

Body{"package_id": "starter" | "standard" | "pro"}
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": "starter"}'

// File management

Files uploaded to the session are available to all tool endpoints as context. Each user has their own isolated file directory on the server. Upload a PDF, CSV, DOCX, or TXT before calling a tool that needs it.

POST/api/v1/uploadBEARER

Uploads a file into the session. Use multipart form data with 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.

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

Returns file content. Text files are returned as {"filename":"...","content":"..."} JSON. Binary files (PDF, Excel, etc.) stream as raw bytes.

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.

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

// Chat

POST/api/v1/chatBEARER · SSE

General LLM chat with awareness of uploaded files. Optionally pass function_list to activate specific tools within the same conversation turn.

Body{"user_input": "...", "function_list": ["research"]}
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

// Research tools

All research endpoints stream SSE progress lines and end with a [TOOL_RESULT] JSON event followed by [DONE]. Tool outputs are also saved as files in the session and can be retrieved via GET /file/{{filename}}.

POST/api/v1/researchBEARER · SSE · 2.5×

Iterative grounded web research across multiple search rounds. Returns a structured research report saved as a Markdown file. Good for broad questions that benefit from synthesising many sources.

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 · 2.0×

Fundamental analysis for one or more tickers. Fetches live market data via yfinance, runs a reverse DCF, and pulls grounded news sentiment. Returns per-asset metrics and a side-by-side comparison as JSON.

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/deep-asset-researchBEARER · SSE · 3.0×

Extended equity research for a single ticker. Pulls annual and quarterly financials, balance sheet, cash flow, and institutional holders from yfinance, then runs three parallel grounded research passes (recent performance, industry/competition, history and future). Synthesises all of this into a six-section research article (current situation, valuation drivers, balance sheet analysis, future outlook, history, industry and competition) with pre-computed markdown tables. Saves a .md file to the session.

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

Portfolio risk analysis for a set of tickers and weights. Returns VaR, CVaR, Sharpe ratio, beta, max drawdown, and a correlation matrix. Tickers and weights can be provided in the prompt or via an uploaded CSV.

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/macro-situationBEARER · SSE · 2.5×

24-hour global market situation report. Covers key events, equity index prices and changes, government bond yields, FX rates, and commodity prices for Americas, Europe, Africa, and Asia-Pacific. No input required. Returns structured JSON and saves a Markdown report to the session.

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": ""}' \
  --no-buffer
POST/api/v1/investment-finderBEARER · SSE · 4.0×

Screens US equities for asymmetric opportunities — cases where market sentiment looks overly pessimistic relative to defensible fundamentals. Give an investment thesis in user_input (e.g. "automation companies will benefit from AI"), or leave it vague/empty to screen for general turnaround candidates. Mention any tickers you have already researched and they will be excluded — or upload a text file (named e.g. researched.txt, portfolio.csv, or anything containing "exclude", "holdings", "watchlist", etc.) with one ticker per line, and its tickers are excluded automatically. The tool builds a candidate universe via grounded search, scores each on price position in its 52-week range, P/S, net cash, and market pessimism (short interest + analyst consensus), then runs a grounded "why is the market bearish?" check on the top candidates and evaluates each against your thesis. Returns the top 4 with full write-ups plus a table of all screened candidates, saved as a Markdown file.

curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/investment-finder \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Automation firms will benefit from AI. Already researched PATH, ROOT."}' \
  --no-buffer

// Document tools

These tools operate on uploaded files. Upload the document(s) first via POST /api/v1/upload, then call the tool endpoint.

POST/api/v1/accountingBEARER · SSE · 1.2×

Processes an uploaded bank statement PDF into a double-entry bookkeeping ledger. Returns a categorised CSV and saves an accounting.xlsx Excel file to the session.

# 1. Upload
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. Process
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 · 1.2×

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

# 1. Upload
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/quarterly-comparisonBEARER · SSE · 2.0×

Compares uploaded quarterly earnings reports (PDF, TXT, DOCX). Works with any number of quarters — detects which quarter each file covers, sorts them chronologically, and produces: revenue/EPS/margin/cash flow tables with QoQ and YoY growth, historical guidance accuracy analysis, a beat-adjusted next-quarter forecast, and sentiment evolution across quarters. Saves a Markdown report and a JSON context file to the session.

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

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

# 2. Compare
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/quarterly-comparison \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Compare the quarterly reports"}' \
  --no-buffer
POST/api/v1/translationBEARER · SSE · 1.5×

Rolling translation of an uploaded document (PDF, TXT, DOCX, MD) into any language. Specify the target language in user_input. Splits the document into ~700-word paragraph-boundary chunks and translates each with a continuously updated context that tracks author tone, writing style, and a growing glossary of established term translations. Saves the complete translation as a Markdown file and the translation context as JSON to the session.

user_inputMust include the target language, e.g. "translate to Finnish"
# 1. Upload document
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/upload \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -F "file=@article.pdf"

# 2. Translate
curl -X POST https://llm-service-438759468271.europe-north1.run.app/api/v1/translation \
  -H "Authorization: Bearer $MMK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_input": "translate to Finnish"}' \
  --no-buffer

// Session utilities

GET/code_blockBEARER

Returns the full result of the most recently completed tool as a string. Use this after a streaming call to retrieve the complete structured output without parsing SSE.

curl https://llm-service-438759468271.europe-north1.run.app/code_block \
  -H "Authorization: Bearer $MMK_API_KEY"
GET/flushBEARER

Clears the session context (conversation history and file references). Files on disk are not deleted — use DELETE /file/{{filename}} for that.

curl https://llm-service-438759468271.europe-north1.run.app/flush \
  -H "Authorization: Bearer $MMK_API_KEY"