Streaming
For compatible chat requests, setstream: true to receive output as it is generated. Consume the stream and close the connection when finished. Streaming can reduce the wait for the first visible text.
Image understanding
Choose a model with image input support, then supplyimage_url content in the messages format accepted by that endpoint. Image pricing depends on the model; check Models and pricing.
Tool calls
Definetools in the request. When the model returns tool_calls, your application executes the allowed tool and sends its result back to the model. The model’s requested call does not itself execute your code.
JSON output
For models supporting JSON mode, setresponse_format to { "type": "json_object" } and explicitly request JSON in the system prompt. Validate the result before using it in your application.