## TL;DR

Set timeouts on the client (timeout=...) so a hung upstream call fails fast instead of holding a worker forever. Switch gunicorn to gevent or eventlet workers for OpenAI-calling blueprints.

## Steps

1. Switch gunicorn to gevent or eventlet workers for OpenAI-calling blueprints.
 The sync SDK releases the GIL on network IO, so greenlets actually help here.
2. Set timeouts on the client (`timeout=...`) so a hung upstream call fails fast
 instead of holding a worker forever. Pair with a retry budget, not infinite
 retries.
3. For generation endpoints, consider `AsyncOpenAI` in an ASGI server instead;
 but do not mix the sync client into async views.

2. - One client per Flask app, created at startup. The sync client is thread-safe
 and shares a connection pool; per-request clients add TLS handshakes and can
 exhaust file descriptors under load.
- Read the key from the environment at startup and fail fast if it is missing.
 A worker that boots without a key fails every request instead of one deploy
 check.

3. - Load-test with concurrency above your worker count; p99 latency should not
 cliff.
- Confirm `timeout` is set: grep client construction sites for the timeout
 parameter.

## When to use

You are seeing this: client.responses.create() (non-streaming) blocks until the model finishes. Use this skill when you run into "Flask + gunicorn: size workers for blocking OpenAI calls".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
