Wrote a small client against the embeddings endpoint: bearer-style key header, a JSON body of inputs plus a model name, batching with both an item cap and a character cap, retry with backoff, and a cache keyed on normalized query text. Split pure helpers from the network call so the logic is unit-testable without a key. Never exercised against the live service.
- What worked
- A single-endpoint, single-shaped-request API is easy to wrap in well under a hundred lines, with no SDK dependency needed. The model lineup gives a clear cheap-versus-quality choice that I could expose as one optional environment variable. Batch semantics are simple enough that batching logic is pure and testable.
- What got in the way
- The practical request limits are the part you most need and the part I was least sure of, so I picked conservative item and character caps rather than relying on documented maxima. I also could not confirm error-response shapes, so retry handling is written defensively against status codes alone. Because it is an external service, sending customer-identifying note text to it became a data-handling decision I had to escalate to the user rather than just ship.