Error Format & Status Codes
Bipkit uses standard HTTP status codes and returns structured JSON error payloads (application/json).
Standard Error Response
Section titled “Standard Error Response”{ "detail": "Missing or invalid API key."}For schema validation errors (422 Unprocessable Entity), FastAPI returns field-level diagnostics:
{ "detail": [ { "loc": ["body", "state"], "msg": "Field required", "type": "missing" } ]}HTTP Status Code Reference
Section titled “HTTP Status Code Reference”| Status | Meaning | Safe to Retry? | Action |
|---|---|---|---|
200 OK |
Request succeeded | — | Process response |
304 Not Modified |
Public DPL metadata unchanged (If-None-Match matched ETag) |
— | Reuse cached manifest/keys/calibration |
400 Bad Request |
Malformed request or unsupported option | No | Fix request payload |
401 Unauthorized |
Missing, revoked, or invalid API key | No | Check Authorization / X-API-Key header |
403 Forbidden |
Key lacks required scope (e.g., keys:manage) |
No | Use a key with the required scope |
404 Not Found |
Resource (request_id, entry_id, key_id) not found in your org |
No | Verify identifier |
422 Unprocessable Entity |
Request body failed schema validation | No | Inspect detail[].loc and fix types |
429 Too Many Requests |
Rate limit or monthly decision quota exceeded | Yes (after backoff) | Honor Retry-After header or check /api/v1/usage/summary |
500 / 502 / 503 / 504 |
Transient server or upstream error | Yes (exponential backoff) | Retry with jitter; fall back to System Two if latency budget is exceeded |
Handling Typed Errors in Official SDKs
Section titled “Handling Typed Errors in Official SDKs”All four official SDKs automatically retry transient 429 and 5xx responses with exponential backoff + jitter (honoring Retry-After). If retries are exhausted or a non-retryable 4xx occurs, catch the typed SDK error:
import { Bipkit, AuthenticationError, RateLimitError, APIStatusError,} from "@bipware-org/bipkit";
const bipkit = new Bipkit();
try { await bipkit.decide({ state, choices });} catch (err) { if (err instanceof AuthenticationError) { console.error("Invalid or revoked BIPKIT_API_KEY"); } else if (err instanceof RateLimitError) { console.warn(`Rate limited; retry after ${err.retryAfter ?? "backoff"}s`); } else if (err instanceof APIStatusError) { console.error(`HTTP ${err.status} (${err.requestId}): ${err.message}`); } else { throw err; }}from bipkit import ( Bipkit, AuthenticationError, RateLimitError, APIStatusError,)
client = Bipkit()
try: client.decide(state=state, choices=choices)except AuthenticationError: print("Invalid or revoked BIPKIT_API_KEY")except RateLimitError as err: print(f"Rate limited; retry after {err.retry_after}s")except APIStatusError as err: print(f"HTTP {err.status_code} ({err.request_id}): {err.message}")import ( "errors" "fmt"
bipkit "github.com/bipware-org/bipkit-go")
_, err := client.Decide(ctx, req)if err != nil { switch { case bipkit.IsAuthenticationError(err): fmt.Println("Invalid or revoked BIPKIT_API_KEY") case bipkit.IsRateLimitError(err): var apiErr *bipkit.APIError if errors.As(err, &apiErr) && apiErr.RetryAfter != nil { fmt.Printf("Rate limited; retry after %.1fs\n", *apiErr.RetryAfter) } default: fmt.Println("Bipkit API error:", err) }}use bipkit::BipkitError;
match client.decide(&req).await { Ok(res) => println!("Top choice: {:?}", res.top_choice), Err(BipkitError::Authentication { message, .. }) => { eprintln!("Invalid or revoked BIPKIT_API_KEY: {message}"); } Err(BipkitError::RateLimit { retry_after_secs, .. }) => { eprintln!("Rate limited; retry after {:?}s", retry_after_secs); } Err(err) => eprintln!("Bipkit API error: {err}"),}