OpenAI function calling: the week tools got a JSON schema
On 13 June 2023, GPT-4 and GPT-3.5 Turbo started returning JSON for functions you describe. The schema, the injection caveat, and an offline check.

On 13 June 2023, GPT-4 and GPT-3.5 Turbo started returning JSON for functions you describe. The new snapshots are gpt-4-0613 and gpt-3.5-turbo-0613. You describe the functions. The model can emit a JSON object of arguments, and it is fine-tuned to detect when a function should be called and to match the signature. The new parameters on /v1/chat/completions are functions and function_call. The price cuts will get the headlines. The sentence I would keep is the one about untrusted tool output.
The same rates and the same feature are in OpenAI’s forum post from that day.
What changed in the API on 13 June 2023?
You send the user message and a description of the functions. The model can answer in prose, or it can return a function_call with a name and an arguments string. The string is JSON. Detecting that a function should be called, and matching the signature, are what these snapshots were fine-tuned to do. Both are model behavior. Your process runs the function after it accepts the JSON.
OpenAI’s examples are send_email(to, body), get_current_weather(location, unit), get_customers_by_revenue(...), sql_query(query), and extract_people_data(...). The API treats them as one kind of object: a name, a signature, and arguments. Mail can leave the building. A SQL string can touch stored rows. The schema describes the arguments. The mailbox and the database role live in your process.
gpt-4-0613 is the snapshot they call out for better function calling. The March token prices stay put. I wrote them down in GPT-4 system card: $0.03 and $0.06 per 1K on the 8,192-token model, $30 and $60 per million, and double that on the 32,768-token model, $60 and $120 per million. The March pins, gpt-4-0314 and gpt-4-32k-0314, are supported until 14 June 2023. The new snapshot is a behavior change at that old rate.
ChatGPT, the free research preview of 30 November 2022, is still the dialogue product. I wrote it up in ChatGPT research preview. Function calling adds a second kind of assistant message: the model proposes a step, and your program decides whether it runs.
Who runs the function?
The model picks the name and fills the arguments. Your code parses the JSON, checks the required fields, runs the function, and sends the result back as the next message. That loop is the feature. If an email goes out, your code sent it after reading the model’s string.
The schema travels with the user message. The model returns a function_call. Your process is the box that can touch a mailbox or a SQL connection. A wrong city on get_current_weather is a bad forecast. A SQL string is a query the database will obey if you execute it. The check in your process, and a person when the action leaves the machine, is the control.
What does one valid payload look like offline?
The script checks one payload offline. The arguments are an example of the shape, not a captured API response. The function is invoice_total: hours, a rate in rupees, and an optional gst_percent. Hours and the rate are required. When gst_percent is absent, the checker fills 18.0. Python 3, no packages, no network, no key.
# check_call.py — validate one function-call payload offline. Python 3, no packages.
import json
schema = {
"name": "invoice_total",
"parameters": {
"type": "object",
"properties": {
"hours": {"type": "number"},
"rate_inr": {"type": "integer"},
"gst_percent": {"type": "number"},
},
"required": ["hours", "rate_inr"],
},
}
model_message = {
"role": "assistant",
"function_call": {
"name": "invoice_total",
"arguments": json.dumps({"hours": 12.5, "rate_inr": 2500}),
},
}
def check(call, fn):
if call["name"] != fn["name"]:
raise SystemExit(f"unknown function {call['name']}")
args = json.loads(call["arguments"])
props = fn["parameters"]["properties"]
for key in fn["parameters"]["required"]:
if key not in args:
raise SystemExit(f"missing {key}")
for key, value in args.items():
expected = props[key]["type"]
ok = (
expected == "number"
and isinstance(value, (int, float))
and not isinstance(value, bool)
) or (
expected == "integer" and isinstance(value, int) and not isinstance(value, bool)
)
if not ok:
raise SystemExit(f"{key} is not {expected}")
return args
args = check(model_message["function_call"], schema)
gst = args.get("gst_percent", 18.0)
subtotal = args["hours"] * args["rate_inr"]
print("arguments:", args)
print(f"subtotal ₹{subtotal:,.0f}, total ₹{subtotal * (1 + gst / 100):,.0f}")
Output (Python 3):
arguments: {'hours': 12.5, 'rate_inr': 2500}
subtotal ₹31,250, total ₹36,875
The example is 12.5 hours at a rate of 2500, with gst_percent omitted. The checker uses 18.0, and the printout is a subtotal of ₹31,250 and a total of ₹36,875.
The check refuses a name other than invoice_total, so the function you described is the allowlist. It parses arguments with json.loads, because that field is a string. It requires hours and rate_inr, and it allows gst_percent to be missing. It also rejects booleans. In Python, bool is a subclass of int, so a bare type test would treat true as a number and as an integer. A string where a number was required, or a non-integer where rate_inr asks for an integer, fails in the same pass. After that, hours times the rate, then the tax default.
What else moved in the price list that day?
Function calling is the change I care about. The same posts also move the 3.5 price list, and the two announcements are easy to mix.
gpt-3.5-turbo-16k offers a 16k context against the 4k default, at $0.003 per 1K input tokens and $0.004 per 1K output tokens, $3 and $4 per million.
Input tokens on gpt-3.5-turbo are cut 25%, to $0.0015 per 1K, $1.50 per million. That input figure is the forum post.
The embeddings model is 75% cheaper. That percentage is the figure the posts give.
GPT-4’s token price stays at the March rates. gpt-4-0613 is called out for better function calling. The 13 June posts do not cut GPT-4’s token price. The lower prices in this announcement are the 3.5 cuts.
A 16k window on gpt-3.5-turbo-16k is a longer GPT-3.5 at $3 and $4 per million. In March the long window was gpt-4-32k: limited access, double the 8k GPT-4 rate, about 50 pages, with long-context quality still being improved. Function calling is on both gpt-3.5-turbo-0613 and gpt-4-0613. I would pin the snapshot I mean, the same way the March note pinned gpt-4-0314, so a schema-matching test stays on those weights.
What is the injection caveat asking you to do?
OpenAI’s caveat is the paragraph I would paste into a design review. A proof-of-concept exploit shows that untrusted data from a tool’s output can instruct the model to perform unintended actions. They tell developers to consume information only from trusted tools, and to confirm with the user before real-world actions such as email, posting, or purchases.
send_email is one of those real-world actions, so the confirm step applies to their own example. get_current_weather returns data. If the next turn treats that data as instructions, the tool output has a path back into the model: the result carries instructions, and the model follows them. That is the proof of concept they are describing.
sql_query has both halves. The model writes the query. The rows come back as tool output, which the caveat says to consume only from a trusted tool. The database role your process uses is the control that matters. The model returns the arguments string. Your process holds the role, and it should be a role you would give a buggy client. extract_people_data pulls a person into that string. Model output can be convincing and subtly false, which is the failure the March system card already named, so I would check the fields against the source before storing them. get_customers_by_revenue is a read, and the ranking still re-enters as the next message. The ChatGPT preview already warned, on day one, about plausible-sounding incorrect answers. A tool result is another way for a wrong figure to arrive looking finished.
I would fail the wrapper in a fixed order: unknown name, missing required field, wrong type, then a person confirming email, posting, purchases, SQL that writes, and any store of personal data. The result sent back should be identifiable as tool output, because that re-entry is a new prompt.
What I would do
I would ship function calling first on invoice_total, a function that stays inside the process. The offline script is the test: name, required fields, types, then a total for 12.5 hours at 2500 with the 18.0 default. If that test fails, the wrapper is wrong before any model is on the path.
I would confirm send_email, posting, and purchases with a person, as the caveat asks. I would put sql_query behind a role fit for a buggy client, and behind a person when the statement writes. I would keep get_customers_by_revenue off a real warehouse until the rows are treated as data, and I would hold extract_people_data until the fields are checked against the source. Weather can go earlier. A wrong city stays inside the answer.
I would pin gpt-4-0613 or gpt-3.5-turbo-0613. If the workload fits the 4k default, the 3.5 input rate is $1.50 per million. If it needs the longer 3.5 window, gpt-3.5-turbo-16k is $3 and $4 per million. GPT-4’s token price stays at the March rates. The embeddings line is the 75% cut. The sources for the day are OpenAI’s function-calling post and the forum post of 13 June 2023.
Update, 29 October 2026
The loop in this post is still the loop. The model proposes a name and an arguments string. Your code runs the function. What is MCP? is the later protocol for how a host finds those tools and calls them on a server, and the invoice fixture here, 12.5 hours at 2500 with the 18.0 default, is the same one used there. When the cost you care about is a pile of tool schemas sitting in the prompt, the follow-up is code execution with MCP. The injection caveat, untrusted tool output that instructs the model, is the same family of failure as AI browsers and prompt injection, where the untrusted text arrives in a page. Confirm before email, posting, or a purchase. That instruction is the one I would still paste into a review.