BotNetwork

Talking to OpenAI-compatible APIs from bots

Base URLs, keys, timeouts and aborting streams.

Guide1 min readUpdated

Why it matters

Many hosts expose OpenAI-style /v1/chat/completions; treat base URL, model id and keys as config — and ACK before the call.

Practical steps

  1. Put OPENAI_BASE_URL, API key and model in env.
  2. Set hard timeouts and max tokens on every request.
  3. Strip tool results before logging.
  4. Retry only idempotent reads.
  5. Measure cost per chat id for attribution.

Watch out for

  • Assuming every compatible API streams identically.
  • Logging full prompts with user PII.

Related comparisons and tools