Files
autoreg-skills-max/skills/reverse-proxy-gateway/references/gateway-verification.md

88 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Gateway Verification Checklist
После создания/перезапуска шлюза — полный цикл проверки всех endpoint-ов.
## 1. Health Check
```bash
curl -s http://127.0.0.1:PORT/health \
-H "Authorization: Bearer $KEY" | python -m json.tool
```
Ожидаемый ответ: `pool.total_accounts`, `pool.available`, `models`, `gateway_key`.
## 2. Non-Streaming Chat (N запросов = размер пула)
```bash
for i in $(seq 1 N); do
curl -s -X POST http://127.0.0.1:PORT/v1/chat/completions \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5-nano","messages":[{"role":"user","content":"Say OK"}],"max_tokens":5}' \
| python -c "import sys,json; print(json.load(sys.stdin)['choices'][0]['message']['content'][:30])"
done
```
**Проверяем**: все N запросов возвращают 200 + контент (ротация работает).
## 3. Streaming
```bash
curl -s -N -X POST http://127.0.0.1:PORT/v1/chat/completions \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5-nano","messages":[{"role":"user","content":"Say hi"}],"max_tokens":10,"stream":true}' \
--max-time 20
```
**Проверяем**: NDJSON/SSE чанки с `data:` + завершающий `data: [DONE]`.
**ВАЖНО**: не тестировать streaming через `execute_code` (Python `resp.read()` вешает инструмент). Только `curl -N`.
## 4. Tool Use
```bash
curl -s -X POST http://127.0.0.1:PORT/v1/chat/completions \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5-nano","messages":[{"role":"user","content":"What is 15+27? Use calculator."}],"tools":[{"type":"function","function":{"name":"calculator","parameters":{"type":"object","properties":{"expr":{"type":"string"}}}}}],"tool_choice":"auto","max_tokens":100}'
```
**Проверяем**: `finish_reason: "tool_calls"` + `tool_calls[]` с именем функции и аргументами.
## 5. Pool Stats
```bash
curl -s http://127.0.0.1:PORT/health \
-H "Authorization: Bearer $KEY" \
| python -c "import sys,json; d=json.load(sys.stdin); [print(f'{a[\"name\"]}: {a[\"requests\"]} reqs, {a[\"errors\"]} errs, avail={a[\"available\"]}') for a in d['pool']['accounts']]"
```
**Проверяем**: все аккаунты `available=true`, ошибок нет, запросы распределены.
## 6. Models
```bash
curl -s http://127.0.0.1:PORT/v1/models \
-H "Authorization: Bearer $KEY" \
| python -c "import sys,json; d=json.load(sys.stdin); print(f'{len(d[\"data\"])} models')"
```
## 7. Gateway Key Recovery
Если 401 — ключ не в коде, а в state-файле:
```bash
python -c "import json; print(json.load(open('PROJECT_gateway_state.json'))['gateway_key'])"
```
## Expected Full Output
```
HEALTH: 200 | pool: 10 total, 10 avail
NON-STREAMING: 10/10 passed
STREAMING: chunks > 0, text: "Hi there!..."
TOOL USE: 1 tool call, calculator({"expr":"15+27"})
POOL: guest-1..N: 1-2 reqs, 0 errs, avail=True
MODELS: 35
```