File size: 2,758 Bytes
4655dd2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # API Reference
Base: `http://localhost:8000`
Swagger: `http://localhost:8000/docs` (OpenAPI 3.1)
## Health
- `GET /` → `{name, version, endpoints}`
- `GET /api/health` → `{status, model_loaded, has_gpu}`
## Model
- `POST /api/model/load`
```json
{"model_path":"C:\\models\\my-model","dtype":"float16","quantization":"none","device_map":"auto","offload_folder":null,"trust_remote_code":false}
```
Returns `ModelInfo`
- `GET /api/model/status` → `ModelInfo`
- `DELETE /api/model/unload`
- `GET /api/model/validate?path=` → `{valid, reason, details:{safetensors_count,total_size_mb,has_config}}`
- `GET /api/model/list?base_path=` → `{models:[{path,name,safetensors_count,size_mb}]}`
## Inference
- `POST /api/generate`
```json
{"prompt":"Hello","messages":null,"max_new_tokens":512,"temperature":0.7,"top_p":0.9,"stream":true}
```
- `stream:false` → `{text, stats:{ttft_ms,tokens_per_sec}}`
- `stream:true` → `text/event-stream` `data: {"type":"token","token":"...","tokens_per_sec":12.3}`
- `POST /api/chat/completions` (alias)
## Telemetry
- `GET /api/telemetry/` → `TelemetrySnapshot`
- `GET /api/telemetry/history?limit=120` → `TelemetrySnapshot[]`
- `WS /ws/telemetry` → pushes `TelemetrySnapshot` every 1s
## Benchmark
- `GET /api/benchmark/suites` → `{reasoning:[],coding:[],arabic:[],summarization:[]}`
- `POST /api/benchmark/run` → `BenchmarkReport` (blocking)
- `POST /api/benchmark/run-stream` → SSE `progress/task_done/done`
```json
{"suites":["all"],"judge_mode":"regex","temperature":0.2,"max_tasks_per_suite":null}
```
- `GET /api/benchmark/results` → `BenchmarkReport[]`
- `GET /api/benchmark/results/{report_id}`
- `DELETE /api/benchmark/results/{report_id}`
## Custom Benchmark
- `POST /api/benchmark/custom/scan?folder_path=` → `{files_found,total_tasks,language_counts,preview}`
- `POST /api/benchmark/custom/run-from-folder?folder_path=&judge_mode=&temperature=` → `{report,meta,scan}`
- `POST /api/benchmark/custom/upload` (multipart `files`) → same
- `GET /api/benchmark/custom/formats`
- `GET /api/benchmark/custom/meta/{report_id}`
## Share
- `POST /api/share/{report_id}` → `{token, share_url, full_url}`
- `GET /api/share/{token}` → `BenchmarkReport`
- `GET /api/share/` → `[{token,report_id}]`
- `DELETE /api/share/{token}`
## Export
- `GET /api/export/json?report_id=` → `application/json`
- `GET /api/export/csv?report_id=` → `text/csv` (utf-8-sig)
- `GET /api/export/pdf?report_id=` → `application/pdf` (Unicode)
- `GET /api/export/pdf/preview` → `{font_path, has_reshaper, supports_arabic}`
## Errors
- `400` → `{detail:"النموذج غير محمل"}`
- `404` → `{detail:"التقرير غير موجود"}`
- `500` → `{detail:"..."}`
|