Turning natural language into API calls is one of the most direct applications of structured output. The user says “refund $25 for order ORD-9842,” and the model produces a validDocumentation Index
Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
Use this file to discover all available pages before exploring further.
POST /refunds request with the right body fields. The schema defines every endpoint as a oneOf branch with const values for method and path, so the model can’t invent endpoints that don’t exist or mix parameters from different calls.
This pattern is especially valuable for internal tools where users interact with backend APIs through a natural language interface. The schema acts as a whitelist of allowed operations.
Goal
Map natural language intent into exactly one valid API call definition, with validated parameters, ready for your backend to execute.Schema contract
Example input
Example output
Implementation tips
conston method and path locks each branch. The model can’t produce"method": "DELETE"for the refund endpoint or change the path. This makes the schema a whitelist of allowed operations.oneOfensures a single action. The model commits to one endpoint per request. If you need multi-step operations, run the model in a loop; don’t try to batch multiple API calls into one schema.- Parameter-level constraints catch bad input early. The
order_idpattern (^ORD-[0-9]{4,10}$) andamountminimum (0.01) reject invalid values at generation time, before your API sees them. - Validate before executing. Even with a strict schema, run the output through your API’s own validation layer. The schema catches structural issues; your API validates business rules (e.g., “this order is not eligible for refund”).
Related docs
- Unions of objects: discriminated unions for routing to different endpoint shapes
- Agent output: structure agent responses with tool calls and final answers
- Conditional Requirements: require different parameters depending on the endpoint
- Composition reference | Object reference