API reference¶
Machine-readable specification: openapi.yaml.
Endpoints¶
GET /health¶
Unauthenticated liveness check, used by the add-in's 测试连接 button. It returns the configured model name and never requires the bearer token.
POST /api/v1/generate¶
Request:
| Field | Type | Required | Notes |
|---|---|---|---|
prompt |
string | yes | Natural-language request; prompts longer than MAX_PROMPT_LENGTH are rejected |
language |
string | no | zh, en, or fr; detected from the prompt when omitted |
current_tree |
object | no | Enables revision mode. The current valid feature tree; the server returns a complete revised tree. Limited by MAX_TREE_LENGTH and validated with the same rules as a model response. |
context |
object | no | Read-only document snapshot: document_type, document_name, units, body_count, feature_count, bbox_mm, features, and selection. Unknown keys are dropped; limited by MAX_CONTEXT_LENGTH. |
A revision request adds the current tree and, optionally, the document context:
{
"prompt": "把四个孔改成直径 12mm,离边 15mm",
"current_tree": {
"features": [
{
"feature_type": "extrude",
"params": { "plane": "前视基准面", "shape": "rectangle", "length": 200, "width": 100, "depth": 20 }
}
]
},
"context": {
"document_type": "part",
"units": "mm",
"body_count": 1,
"feature_count": 5,
"bbox_mm": [0, 0, 0, 200, 100, 20],
"features": [
{
"name": "Boss-Extrude1",
"type": "Extrusion",
"dimensions": [
{ "full_name": "D1@Sketch1@Part.Part", "name": "D1@Sketch1", "value_mm": 50 }
]
}
],
"selection": [{ "type": "face", "normal": [0, 0, 1], "radius_mm": 5 }]
}
}
Success — 200 OK with the feature tree:
{
"model_name": "Mounting plate",
"features": [
{
"feature_type": "extrude",
"name": "Base",
"params": {
"plane": "前视基准面",
"shape": "rectangle",
"length": 200,
"width": 100,
"depth": 20
}
}
]
}
Errors use a small envelope:
| Status | Condition |
|---|---|
400 |
Missing, non-string, too long, or empty prompt; no valid feature envelope; invalid feature parameters; or an invalid or oversized current_tree / context |
401 |
VULCAN_API_TOKEN is set and the bearer token is missing or wrong |
429 |
The per-IP rate limit was exceeded |
503 |
The LLM provider is unreachable or the request timed out |
500 |
The LLM response could not be parsed, or an unknown server error occurred |
Bring-your-own-key headers (optional). The add-in can override the server's provider for a single request:
| Header | Purpose |
|---|---|
X-LLM-API-Key |
Provider key, used for this request only |
X-LLM-Base-URL |
OpenAI-compatible base URL; ignored when VULCAN_ALLOW_CUSTOM_LLM_BASE_URL=false |
X-LLM-Model |
Model name |
X-LLM-Provider |
openai or anthropic; selects the request shape. Falls back to LLM_PROVIDER when omitted. |
Omitted headers fall back to QINIU_* and LLM_PROVIDER. Values are length-limited, the base URL must use http or https, and neither keys nor prompts are written to the server log.
POST /api/v1/generate/stream¶
Same request body and headers as /api/v1/generate. The response is text/event-stream; each event is a data: line containing one JSON object.
| Event | Payload |
|---|---|
delta |
{"type":"delta","text":"..."} for each provider text chunk |
status |
{"type":"status","message":"...","attempt":1} while the server is repairing a rejected output |
result |
{"type":"result","data":{...},"meta":{"repair_attempts":0}} with the validated feature tree |
error |
{"type":"error","message":"...","status":400} when the request or model output is invalid |
The server accumulates the text, parses the JSON, and applies the same envelope and feature validation as the non-streaming endpoint. A non-streaming response reports repairs with the X-Vulcan-Repair-Attempts header.
Privacy. The optional document context is sent to the configured model provider. It contains the document name, units, bounding box, top-level feature names, and selected-object geometry; it never contains file contents.
Security. The server supports an optional bearer token and per-IP rate limiting. It does not terminate TLS and has no user accounts. Keep HOST=127.0.0.1 or put it behind a TLS reverse proxy, set VULCAN_API_TOKEN, and never enable Flask debug mode in production.