Function call mock generator
Building the code that handles an LLM’s tool calls means you need example tool-call payloads to test against — but calling the real API for each one is slow and costs tokens. This tool reads your function/tool JSON Schema and synthesises type-correct mock arguments, giving you instant fixtures for your parsing and handler logic.
How it works
The input is parsed as JSON and the tool locates the parameters schema — under
function.parameters (OpenAI), input_schema (Anthropic), or at the top level
(bare JSON Schema). It then walks the schema recursively:
enumfields take their first option (real, allowed values)- Strings derive a plausible value from the property name — an
emailfield becomes[email protected], auserIdbecomesuser_123 - Numbers take the midpoint of
minimum/maximumif declared, otherwise default to0 - Booleans default to
true - Arrays produce two sample items of the declared item type
- Nested objects recurse through all their properties
Generation is deterministic: the same schema always yields the same mock. The result is wrapped in a realistic tool-call envelope — including id, type, and function.name — that you can paste straight into a test fixture.
Worked example
For an OpenAI-style schema like this:
{
"name": "create_order",
"parameters": {
"type": "object",
"properties": {
"product_id": { "type": "string" },
"quantity": { "type": "integer", "minimum": 1, "maximum": 100 },
"priority": { "type": "string", "enum": ["low", "normal", "high"] }
},
"required": ["product_id", "quantity"]
}
}
The generator produces a mock tool call like:
{
"id": "call_mock_abc123",
"type": "function",
"function": {
"name": "create_order",
"arguments": "{\"product_id\":\"product_id_value\",\"quantity\":50,\"priority\":\"low\"}"
}
}
You can feed this directly into the handler under test, or adapt the values by hand before using it as a fixture.
When this is most useful
- Unit-testing handler functions that parse
argumentsstrings and call downstream services — no API tokens needed. - Integration testing schemas across OpenAI and Anthropic formats without maintaining two separate fixture files.
- Rapid prototyping when you want to see what a handler receives before the real model is wired in.
- CI/CD pipelines where deterministic, cost-free fixtures prevent flaky tests and token spend from test suites.
Tips and limitations
- Every property is included. The generator emits all defined properties, not just the
requiredones, so the mock exercises your full parsing path. - Use enums for realistic values. The generator picks the first enum option — a real, allowed value — making the mock more meaningful than a generic placeholder.
- It validates structure, not semantics. The mock satisfies the schema’s type constraints; it will not invent business-meaningful data. Adjust specific values by hand where your tests assert on exact content (for example, a specific order ID format).