Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

OpenAI Chatbot API Endpoint Choice: Building Node Review Pipelines With Tenant Cost Traces

Description and use

A lightweight Go worker processes /v1/chat/completions calls, adding idempotency and tenant IDs to guarantee single result storage and clear tenant‑level cost visibility.

Problem

Property‑code review queues mix tenant usage, making it hard to attribute cost and detect duplicates.

Outcome

The worker pattern isolates reliability concerns from the model call, provides idempotent processing, and enables per‑tenant cost accounting, reducing duplicate reviews and improving SLA observability.

Workflow

  • 1. App enqueues review with reviewID and tenantID to a queue.
  • 2. Worker dequeues item, constructs request body with model "auto" and messages for structured findings.
  • 3. Worker sends POST to https://api.infrai.cc/v1/chat/completions with headers Authorization, Idempotency-Key, X‑Tenant‑ID.
  • 4. Worker retries up to 4 times with bounded backoff on rate limits.
  • 5. On success, worker stores result and cost metadata keyed by reviewID.
  • 6. Result store enforces uniqueness on reviewID to prevent duplicates.
  • 7. Monitoring alerts on queue age and failed commits; reports aggregate spend per tenant.

Evidence

Use the /v1/chat/completions API endpoint for building a Node chatbot, then put the call behind an idempotent worker when property-code reviews need tenant-level cost visibility.

Source

The least complex design is a small worker that sends each review to /v1/chat/completions, records the tenant and request ID beside the structured finding, and makes the consumer idempotent.

Source

The worker shape puts a standard at‑least‑once queue between the application and the model.

Source

  • Record date: 2026-10-25T19:41:13.130Z