Socket hang up (OpenAI)

What engineers usually see

  • TCP socket closes unexpectedly during request
  • Common error: "ECONNRESET" or "socket hang up"
  • No response received from provider
  • Unclear if issue is network, load balancer, or provider

Why this is hard to debug

Socket errors happen between client and provider. Standard logs don't show which layer failed. Receipts track the full network path and identify where the connection dropped.

Minimal repro

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_OPENAI_KEY',
  baseURL: 'https://aibadgr.com/v1'
});

try {
  const response = await client.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{role: 'user', content: 'test'}]
  });
  console.log(response);
} catch (error) {
  console.error('Socket error:', error.message);
}

This request routes through AI Badgr and returns a stable request ID that links to an execution record.

Note: AI Badgr is OpenAI-compatible and works as a drop-in proxy. No SDK changes required — only the base_url changes.

What a per-request execution record makes visible

  • Network layer where failure occurred
  • Connection attempt timeline
  • Provider reachability status
  • Retry attempts made by proxy
  • Root cause of socket closure

Run 1 request → get receipt

Change your base URL to https://aibadgr.com/v1 and run your request.

The response includes an X-Badgr-Request-Id header that links to a receipt showing latency, retries, tokens, cost, and failure stage for that specific execution.

Not the engineer?
Share this page with your dev and ask them to run one request through AI Badgr. That's all that's needed to get the receipt.

This kind of thing only makes sense when you can actually see what happened to a single request from start to finish, instead of trying to piece it together from scattered logs.