Skip to main content
Chat exposes response_format, tools, and tool_choice. Check model support first, then parse and validate results in your application.

JSON output

This example requires a model supporting JSON mode. Install dependencies using the SDK guide, set APIONE_API_KEY and APIONE_MODEL, save as json_output.py, and run python json_output.py.
json_object requests JSON output. Your application still checks the finish reason, parses the result, and validates fields and allowed values. Asking for JSON in a prompt does not replace a schema constraint.

JSON Schema

response_format can also carry json_schema. Supported schema subsets and strict-mode behavior depend on the model. Check model parameters before choosing constraints, and recheck the schema when switching models.

Tool call flow

  1. Declare permitted functions and parameters in tools. Use tool_choice if needed, after confirming model support.
  2. Read choices[].message.tool_calls. There may be multiple calls, and ordinary text may be empty.
  3. Keep the assistant message. Validate tool names, parse arguments, and check user permissions. Confirm external writes as required by your application before execution.
  4. Send each result as a role: "tool" message, with tool_call_id matching the original call’s id.
  5. Request the model again with the updated history and read the final answer. Limit the number of tool-call rounds in the application.
APIONE returns tool requests; your application executes functions. Do not pass unvalidated model-generated URLs, SQL, or commands directly to an executor.

Compatibility

For unsupported_parameter, remove optional fields and verify a minimal chat request before restoring them individually. Recheck JSON, tools, and streaming when changing models. See the APIONE Chat reference for complete fields.