C.W.K.
Stream
Lesson 01 of 07 · published

Why Go Raw?

~22 min · raw-http, rationale, sdk-limits

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

While the official SDK is excellent, there are compelling reasons to call the OpenAI API directly via HTTP:

  • OAuth tokens — ChatGPT account authentication (Codex CLI pattern) requires custom bearer tokens.
  • Unofficial endpoints — Access endpoints not yet in the SDK.
  • Custom streaming — Fine-grained control over SSE parsing and event handling.
  • Full HTTP control — Custom headers, proxies, transport layers, logging.
  • Minimal dependencies — Only need httpx instead of the full openai package.
  • Framework integration — Embed API calls into existing HTTP client infrastructure.

The trade-off is clear: you give up auto-retry, typed responses, and convenience methods. But you gain complete control over every byte on the wire.

External links

Exercise

Re-implement one SDK call as raw httpx. Time both. Verify you get the same content. Note one thing the SDK was doing that you forgot.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.