Streaming
Setstream: true to receive tokens as they are generated.
usage object in every chunk.
Errors
Error response bodies specify the issue.code disambiguates the error, and for rate limits, type specifies the triggered limit.
Retry 429 and 5xx with exponential backoff and jitter. Prefer the delay we advise,
retry-after-ms first and then retry-after, over an interval of your own. Do not retry 400, 401, 402 or 404, and do not retry anything carrying x-should-retry: false: the answer will not change until you do something about it.
A 429 means one of your three per-minute budgets is empty — see Rate limits for what they are and how to read the headers that report them.