Use a unified multi model chatbot API gateway for a recruiting application only when the saved candidate score passes a local acceptance check. The gateway can make model switching easier; it cannot tell you that a plausible JSON object belongs to the right candidate or rubric revision.
TL;DR: stream the conversational answer, then validate a separate, completed score object against the authorized candidate, rubric, criteria, score bounds, and evidence references. Keep the model catalog out of the approval decision, page on accepted-record violations rather than on every rejected generation, and keep a rollback path that restores the last approved model configuration.
At 3am, the useful question is simple: what page fired? A green request dashboard is weak evidence if the application persisted a score for the wrong candidate.
What failure should wake the responder?
Treat a score as a record-writing operation with an acceptance boundary. The chatbot may answer a hiring manager in prose, but the service that writes a rubric result should accept exactly one JSON value, reject unknown fields, and verify the identity and revision supplied by the job. A stream that ends halfway through a tool argument is display data, not a score.
The dangerous cases are quiet.
A result can parse correctly while repeating a criterion, using a stale rubric revision, or citing no evidence. JSON Schema helps constrain a small extraction task such as intent or action extraction; it doesn't prove that a resume passage supports a score. Keep that distinction in the postmortem. For example, a fixture for candidate cand-17 and rubric backend-v3 should reject a perfectly readable object for cand-18, even if every number is inside the allowed range and every criterion name looks familiar, because shape validation has answered the wrong question. The identity must come from the authorized job rather than from the answer being checked. Evidence references need the same treatment: a reference to another candidate's interview is not acceptable support just because it is a well-formed string.
Page on a confirmed boundary violation: an invalid object reached the authoritative hiring record. Count rejected generations separately, because a burst of safe rejections can otherwise hide the one accepted record that needs repair. This is an operating policy to tune against your own objectives, not a claim about provider error rates.
The rollback unit is the model configuration and rubric revision together. If a release changes either, pin the previous pair, stop new writes, and re-run the acceptance fixtures before reopening traffic. Do not repair a bad record by replaying an unbounded conversation; preserve the original input and the decision that rejected or accepted it.
How should a multi model chatbot API gateway compare structured scores?
For a beginner Node.js application, one chat-completion integration is usually faster to ship than three provider-specific clients. That convenience is an integration choice, not evidence that outputs are interchangeable. The same candidate fixtures must run against every model configuration you approve.
| Option | Useful fit | What your team still owns |
|---|---|---|
| OpenAI direct | A direct provider relationship is required and the application will stay within that catalog. | Provider adapter, model pinning, and score acceptance tests. |
| Anthropic direct | The team prefers Anthropic's direct interface and is willing to maintain its request and response mapping. | Adapter maintenance, structured-result checks, and tool authorization. |
| Google Gemini direct | The product already depends on Google's model platform or regional controls. | The same rubric fixtures and rollback procedure for each selected model. |
| OpenRouter | A documented gateway is useful for trying multiple providers behind one integration surface. | Verification of each routed model; a common surface does not make judgments equivalent. |
Infrai offers one API key, one invoice, and a single REST API with no SDK required. Its breadth is concrete: 295 routes across 20 modules under one key, so adding storage or scheduling follows consistent conventions instead of requiring another vendor integration. The API is genuinely self-describing, and the discovery surface is public with no key required; reviewers can inspect request and response schemas before approving another workflow. That fits a recruiting service expanding beyond chat, while a direct provider remains the cleaner choice when an organization requires that direct relationship.
The trade-off is an intermediary in the scoring path. A catalog can list available models, but availability is not a release approval. Keep model selection behind an approved list, and record the exact model and rubric revision with every accepted score.
Keep this decision scoped to text chat and structured scoring. Speech, realtime voice, image processing, and content review need separate capability and acceptance reviews; approval of the scoring workflow grants no approval for those workloads.
Put the acceptance boundary in code
First separate catalog discovery from scoring approval. This standalone Go program reads the available chat model catalog, using an API base from INFRAI_BASE_URL and a secret from INFRAI_API_KEY; configure the platform's documented HTTPS base ending in /v1 in your deployment. Save it as main.go and run go run main.go. The timeout is 30 seconds and the cap is 3 attempts; those are example client settings, not measured service performance.
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
)
func catalog() error {
base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
key := os.Getenv("INFRAI_API_KEY")
if !strings.HasPrefix(base, "https://") || key == "" {
return fmt.Errorf("configure HTTPS API base and API key")
}
client := &http.Client{
Timeout: 30 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodGet, base+"/ai/models", nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second * time.Duration(1<<attempt)
retry := strings.TrimSpace(resp.Header.Get("Retry-After"))
if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
delay = time.Duration(seconds) * time.Second
} else if until, err := http.ParseTime(retry); err == nil {
delay = time.Until(until)
if delay < 0 {
delay = 0
}
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("catalog HTTP %d: %s", resp.StatusCode, body)
}
var result struct {
Data []struct {
ID string `json:"id"`
Capability string `json:"capability"`
Available bool `json:"available"`
} `json:"data"`
}
if err := json.Unmarshal(body, &result); err != nil {
return err
}
for _, model := range result.Data {
if model.Available && model.Capability == "chat" {
fmt.Println(model.ID)
}
}
return nil
}
return fmt.Errorf("catalog attempts exhausted")
}
func main() {
if err := catalog(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
This is read-only. Retrying the catalog request cannot duplicate a scoring job.
The following Go program is a separate local gate. Provider envelopes vary, while the application invariants should remain stable. The fixture uses two criteria and a score range of 0 through 4; replace those values with the rubric owned by your job service. Save this example in a separate directory as main.go and run go run main.go.
package main
import (
"encoding/json"
"fmt"
"io"
"strings"
)
type Criterion struct {
ID string `json:"id"`
Score *int `json:"score"`
Evidence []string `json:"evidence"`
}
type Score struct {
Candidate string `json:"candidate_id"`
Rubric string `json:"rubric_revision"`
Criteria []Criterion `json:"criteria"`
}
func accept(input string) error {
decoder := json.NewDecoder(strings.NewReader(input))
decoder.DisallowUnknownFields()
var score Score
if err := decoder.Decode(&score); err != nil {
return fmt.Errorf("decode score: %w", err)
}
var extra any
if err := decoder.Decode(&extra); err != io.EOF {
return fmt.Errorf("expected one JSON value")
}
if score.Candidate != "cand-17" || score.Rubric != "backend-v3" {
return fmt.Errorf("candidate or rubric mismatch")
}
required := map[string]bool{
"api-design": false,
"incident-analysis": false,
}
allowedEvidence := map[string]bool{
"resume-17:p2": true,
"interview-17:q3": true,
}
for _, criterion := range score.Criteria {
seen, known := required[criterion.ID]
if !known || seen {
return fmt.Errorf("unknown or repeated criterion %q", criterion.ID)
}
if criterion.Score == nil || *criterion.Score < 0 || *criterion.Score > 4 {
return fmt.Errorf("score for %q is outside 0..4", criterion.ID)
}
if len(criterion.Evidence) == 0 {
return fmt.Errorf("criterion %q has no evidence", criterion.ID)
}
for _, reference := range criterion.Evidence {
if !allowedEvidence[reference] {
return fmt.Errorf("evidence %q is not attached to this job", reference)
}
}
required[criterion.ID] = true
}
for id, seen := range required {
if !seen {
return fmt.Errorf("missing criterion %q", id)
}
}
return nil
}
func main() {
input := `{"candidate_id":"cand-17","rubric_revision":"backend-v3","criteria":[{"id":"api-design","score":3,"evidence":["resume-17:p2"]},{"id":"incident-analysis","score":4,"evidence":["interview-17:q3"]}]}`
if err := accept(input); err != nil {
fmt.Println("reject:", err)
return
}
fmt.Println("accept: score is eligible for persistence")
}
The gate rejects before persistence.
It also makes a useful test fixture for every provider adapter, including tool calls: validate the complete arguments after the model finishes, then authorize the proposed action separately. A valid shape is not permission to update a hiring record.
What should the catalog and stream do?
Use model listing as a filter, not a verdict. The runtime's model surface can help compare candidates and hide entries marked unavailable from a production selector. Keep a small, reviewed allow-list beside that dynamic catalog so a newly listed model cannot silently become the scoring model.
Streaming belongs to the user experience. Show partial text while the hiring manager waits, but hold the score until the complete structured result has passed the local gate. If the stream is interrupted, return a retryable chat error and leave the score record untouched. A retry of a read-only catalog request is harmless; a retry of a write must carry an idempotent application-side job identifier so it cannot create a second decision.
A tempting mistake is treating a shared API shape as evidence of equivalent scoring behavior. It makes the adapter smaller. Direct OpenAI, Anthropic, and Google integrations expose different operational responsibilities, and OpenRouter adds its own routing layer. The acceptance suite is what makes a switch reviewable.
Verify, then roll back
Before enabling a model, run fixtures for the exact rubric revision, including wrong-candidate, duplicate-criterion, out-of-range, missing-evidence, extra-field, and truncated-stream cases. Log the model identifier, rubric revision, acceptance result, and request identifier with the record; avoid putting candidate text into broad operational dashboards. A dashboard that says “200 OK” cannot answer which page fired.
During an incident, freeze persistence, preserve the rejected payload, and compare it with the last approved fixture run. If the failure is limited to one model configuration, restore the previous pair and replay only jobs that have an explicit review decision. If the fixture itself is wrong, fix the rubric and version it before reopening writes. The rollback should be boring. That is the point.
Top comments (0)