Demo error codes#
| Command | What it does |
|---|
413 body_too_large | Body over 4,096 bytes |
|---|
408 request_timeout | Body stops before Content-Length |
|---|
415 unsupported_media_type | Content type is not JSON |
|---|
400 bad_json | Body is not a JSON object |
|---|
422 text_too_long | Text over 500 characters |
|---|
422 control_characters | Text has control characters |
|---|
429 rate_limited | Token bucket empty. Read Retry-After |
|---|
503 usage_cap_reached | Daily cap reached. Read Retry-After |
|---|
Resume a streamed answer#
Gateway fallback policy#
| Factor | 2xx | 429 or 5xx | Other status | Cancellation |
|---|
ClassifyStatus | success | retry | terminal | none |
|---|
| Next provider | No | Yes | No | No |
|---|
| Route state | completed | exhausted at end | terminal-error | cancelled |
|---|
| Proxy reply | Upstream body | 502 at end | 502 | 504 |
|---|
Gateway providers file#
{"providers": [
{"name": "primary", "url": "http://127.0.0.1:11434/v1/chat/completions"},
{"name": "backup", "url": "http://127.0.0.1:11435/v1/chat/completions",
"key_env": "ORCHARD_BACKUP_KEY"}],env var name, not the key
"max_attempts": 2,1 to 16, one visit per provider
"max_response_bytes": 65536,1 byte to 16 MiB
"timeout_ms": 4000}1 to 5000, whole route
Project tasks#
| Task | Code |
|---|
| Make a work folder | python3 scripts/project_test.py <project> --init /tmp/<project>-work |
|---|
| Grade one stage | python3 scripts/project_test.py <project> --stage 1 --path /tmp/<project>-work --strict |
|---|
| Stream demo, drop then resume | cd projects/streaming-answer-recovery/solution && python3 demo.py |
|---|
| Read your own SSE endpoint | node --experimental-strip-types cli.ts <url> /tmp/trace.json |
|---|
| Gateway demo, 503 then backup | cd projects/llm-gateway-with-fallbacks/solution && go run . |
|---|
| Run the gateway proxy | go run . --config /tmp/providers.json --listen 127.0.0.1:8088 |
|---|
| Call the proxy | curl --fail-with-body http://127.0.0.1:8088/v1/chat/completions --data-binary @fixtures/request.json |
|---|
Targets and checklist#
- P50 latency under 2s. P99 latency under 10s.
- Cache hit rate over 30%. Guardrail block rate under 5%.
- Cost per request under $0.01.
- Rate limit each user at 10 to 50 requests per minute.
- Load test with 100 concurrent users before launch.
Q&A#
- Why POST and not
EventSource? EventSource sends GET only. GET puts the input in logged URLs.- Model fails after status 200?
- The status is sent. Send an
error event in the stream. - What is in an error body?
code, message, hint and request_id.