Files
autoreg-skills-max/skills/conol-automation/references/gateway-omp-key-matching.md

73 lines
2.2 KiB
Markdown

# Conol.ai Gateway — OMP Key Matching
## Problem
Gateway starts with a random API key but OMP expects a specific one.
## Architecture
```
OMP (providers.yml) Gateway (port 9999)
├─ apiKey: test → ├─ /health → api_key_prefix
└─ baseUrl: ...9999/v1 ├─ /v1/chat/completions → Bearer auth
└─ /v1/models → Bearer auth
```
If the keys don't match: OMP gets HTTP 401 → falls back to next provider → "hermes-conol" NEVER works.
## Two Gateways, Two Key Mechanisms
### Gateway v3 (conol_github/conol_pool_gateway.py)
Uses `ENI_POOL_KEY` env var. Old stable gateway (20+ hour uptime).
```bash
cd C:\Users\User\Desktop\conol_github
ENI_POOL_KEY=test /c/Users/User/AppData/Local/Programs/Python/Python311/python.exe conol_pool_gateway.py
```
If `ENI_POOL_KEY` is not set, generates random `sha256(os.urandom(32))[:32]` → OMP will fail.
### Gateway v4 (conol_autoreg/gateway.py)
Reads from `config.json` → `gateway.api_key`. Default: `test`.
```bash
cd C:\Users\User\Desktop\conol_autoreg
/c/Users/User/AppData/Local/Programs/Python/Python311/python.exe gateway.py
```
Also respects `ENI_POOL_KEY` and `ENI_POOL_KEY_OVERRIDE` env vars (override priority: ENI_POOL_KEY_OVERRIDE > ENI_POOL_KEY > config.json).
## How to Verify Match
```bash
# Get gateway's actual key prefix
curl -s http://127.0.0.1:9999/health | python -c "import sys,json; print(json.load(sys.stdin)['api_key_prefix'])"
# Get OMP's expected key
python -c "
import yaml
with open(r'C:\Users\User\.omp\agent\providers.yml') as f:
c = yaml.safe_load(f)
print(repr(c['providers']['hermes-conol']['apiKey']))
"
```
Both should show `test...`.
## Common Failure Mode
Gateway was started without `ENI_POOL_KEY` → random key generated (e.g., `bfae749f...`). OMP has `test`. Result: OMP calls return 401, "hermes-conol" provider silently fails, all traffic falls back to echogate.
## Fix
1. Kill old gateway process
2. Restart with correct key:
```bash
# For conol_github gateway:
ENI_POOL_KEY=test python conol_pool_gateway.py
# For conol_autoreg gateway:
python gateway.py # reads test from config.json
```
3. OMP picks up immediately — no restart needed