Skip to main content

Basic call

Use POST /v1/chat/completions with a chat-completions model, Bearer authentication, a messages array, and a reasonable max_completion_tokens limit.

Streaming

Set stream: true. In Python, iterate over stream and read nonempty chunk.choices[0].delta.content. In JavaScript, use for await and read choices[0]?.delta?.content. Native HTTP SSE ends with [DONE]; do not use a Responses response.output_text.delta event parser.

Choose the right protocol

Chat Completions has different input and output formats from Responses. Codex CLI uses Responses; Claude Code uses Messages. For platform response storage, lookup, and continuation, see Responses. Tools, structured output, and multimodal input depend on model and upstream support. Disable automatic retries and check logs before generating again after disconnection.