---
title: "Analyze Stock"
method: POST
path: "/api/ai/analyze"
tags: ["ai"]
---

# Analyze Stock

`POST /api/ai/analyze`

## Request

- Base URL: `https://api.equity-rank.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.equity-rank.com/api/ai/analyze`
- Auth: HTTP bearer

POST /api/ai/analyze — streams expert AI analysis as Server-Sent Events.

Defense layers (in order):
  L1: slowapi IP rate limit — 10/min per IP (burst cap)
  L2: platform daily cost ceiling — global $/day circuit breaker
  L3: force_refresh cooldown — 1 per user per hour
  L4: atomic reserve_ai_call RPC — fixes TOCTOU + disconnect abuse
      (includes per-user concurrency cap)
  L5: release_ai_call in finally — refunds on upstream error, frees slot

## Request body

- AIAnalysisRequest: Request body for the AI stock analysis streaming endpoint.
  - `symbol` string, required
  - `model` string
  - `force_refresh` boolean

## Response `200`

Successful Response

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/equity-rank/apis/equity-rank-api.md) · [All operations](https://skmtc.dev/equity-rank/apis/equity-rank-api/llms.txt) · [OpenAPI document](https://skmtc.dev/equity-rank/apis/equity-rank-api/revisions/c2f2463fee33?raw)
