Chat Completions
Save the following asrequest.json, replacing YOUR_MODEL_ID with an actual chat model ID:
choices[0].message.content on success. Text may be empty for tool calls; inspect tool_calls and finish_reason as well.
Responses
Confirm Responses support, replacerequest.json with the following content, and call /responses:
status first. Find items with type=message in output, then read text from their content entries with type=output_text. Raw HTTP JSON does not guarantee a top-level output_text; the SDK provides that convenience property.
Requests and results
--fail-with-body preserves the response body and exits with a nonzero status on HTTP errors. --max-time 60 is this example’s client timeout, not a server processing deadline. A timeout does not prove that the upstream did not execute the request; avoid immediately resubmitting it.
For streaming, add "stream": true to the JSON and --no-buffer to cURL. Handle SSE events instead of parsing the whole response as JSON.
Investigate errors
简体中文