Short answer. Send a
toolsarray of JSON Schema functions toPOST https://api.plugsky.com/v1/chat/completions. The model replies with either text ortool_calls. Your code validates the arguments, executes the function, appends arole=toolmessage carrying the matchingtool_call_id, and calls again until the model answers without asking for a tool. That loop is the whole mechanism. Production quality comes from schema design, authorisation, timeouts, idempotency and a record of every call.
Key facts
| Endpoint | POST https://api.plugsky.com/v1/chat/completions; the docs also accept https://plugsky.com/v1 as a host alias |
|---|---|
| Request shape | tools array of JSON Schema function definitions, plus optional tool_choice and parallel_tool_calls |
| Response shape | Assistant message with tool_calls; each call carries an id, a function name and JSON-encoded arguments |
| Loop | Model requests a call, your code executes it, you return role=tool results, the model continues |
| Parallel calls | Several tool calls can arrive in one response; dispatch them concurrently and answer each one by ID |
| tool_choice | auto, none or a named function; a named choice is the deterministic option |
| JSON mode | response_format set to {"type":"json_object"} for JSON-only output without tool definitions |
| Strict schemas | strict:true on a function restricts generation to the declared schema |
| Model catalogue | all public model IDs behind one API; routine tool calls and planning steps can use different tiers |
| Product status | Function calling, streaming, JSON mode and the agents API are live |
Short answer.
- Tools are JSON Schema objects with descriptions, required fields and no invented properties.
- Parallel tool calls and tool_choice follow the OpenAI shape, so migration is mostly a base URL change.
- Strict mode narrows the output to your schema; it does not make the arguments trustworthy.
- Budget for 5–20 tools in a working set; every definition consumes context on every request.
- Log the call, the arguments, the result and the latency. Without that record you cannot debug or audit an agent.
How it works, step by step
- Define each tool as a JSON Schema object with a name, a description and typed parameters.
- Send the definitions in the
toolsarray on/v1/chat/completions. - Detect
tool_callsin the response and parse the JSON arguments. - Validate the arguments, check authorisation, execute the function and append a
role=toolmessage with the result. - Loop until the model returns a normal message with no tool calls.
- Add
tool_choiceor strict mode where you need determinism. - Return tool errors as structured payloads the model can see and react to.
Try it yourself
The tester sends a tool definition and returns the raw call, which is the quickest way to confirm the request shape before wiring the loop into an application.
Open the function calling tester →
The function calling loop
The loop has five steps: send the conversation plus your tools array, receive either normal text or one or more tool calls, execute the requested functions, append a role=tool message with each result, and continue until the model answers without asking for tools. Each tool result must carry the tool_call_id from the request it answers, because a parallel response can contain several calls and the model needs to match results to requests.
Two details break more implementations than anything else. First, arguments arrive as a JSON string, not an object, so parse them and handle a parse failure as a normal error path. Second, a role=tool message is not a user message: it is a machine result, and it should be as terse and as structured as the model needs.
Because the shape follows the OpenAI schema, the same loop works with the official SDKs and with frameworks such as LangChain, LlamaIndex and the Vercel AI SDK. Schema validation still belongs in your code. Treat every argument as untrusted input even when the schema is strict, because strict mode constrains the shape, not the value.
The function calling feature page explains what the platform supports, and the tools API reference carries the accepted request fields and response objects. Read both before you write a schema, because the feature summary does not list every field the API accepts.
Tool definition rules
Tools are JSON Schema objects. Use type: object with properties and required, and support string, number, integer, boolean, array, enum and nested objects. For strict mode, set additionalProperties: false and list every property in required, because the schema subset used for strict generation expects a closed object.
Descriptions on every field matter more than the field names. The model uses them to decide what to call and when. Write the description as an instruction to a new colleague: what the value means, the expected format and one example. “Customer ID” is weaker than “Numeric customer ID from the billing system, for example 10482; not an email address”.
Keep the tool count deliberate. The working range is roughly 5–20 tools; beyond that, selection quality falls and every definition consumes context on each request. If you need more, group tools behind a small number of dispatchers, or split the agent into roles, each with its own short list. The catalogue exposes all public models, so a cheap model can handle routine extraction while a stronger one plans the multi-step calls.
Name tools with a verb and a noun, keep names stable, and version the behaviour behind the name rather than renaming the tool. Renaming a tool breaks prompts, logs and evaluations at the same time.
A minimal working loop
The example below uses the official Python SDK against the canonical host. It validates the arguments, answers every tool call by ID, and stops after one round so a failure cannot loop forever.
import json
from openai import OpenAI
client = OpenAI(
base_url="https://api.plugsky.com/v1",
api_key="YOUR_PLUGSKY_KEY",
)
tools = [{
"type": "function",
"function": {
"name": "get_policy_status",
"description": "Return the current status of an insurance policy by its identifier.",
"strict": True,
"parameters": {
"type": "object",
"properties": {
"policy_id": {
"type": "string",
"description": "Policy identifier such as POL-10482.",
}
},
"required": ["policy_id"],
"additionalProperties": False,
},
},
}]
messages = [{"role": "user", "content": "Is policy POL-10482 active?"}]
first = client.chat.completions.create(
model="plugsky-plus",
messages=messages,
tools=tools,
tool_choice="auto",
)
message = first.choices[0].message
if message.tool_calls:
messages.append(message)
for call in message.tool_calls:
try:
args = json.loads(call.function.arguments)
except json.JSONDecodeError:
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps({"error": "arguments were not valid JSON"}),
})
continue
if not isinstance(args, dict) or set(args) != {"policy_id"}:
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps({"error": "unexpected fields"}),
})
continue
result = {"policy_id": args["policy_id"], "status": "active"}
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
final = client.chat.completions.create(
model="plugsky-plus",
messages=messages,
tools=tools,
)
print(final.choices[0].message.content)
Examples use the canonical host https://api.plugsky.com/v1. The public docs also accept https://plugsky.com/v1 as an alias for the same API; it is a hostname alias, not a second backend, and one snippet should use one host.
Parallel calls, JSON mode and agents
Parallel function calling lets the model return several tool calls in one response, and your code can dispatch independent lookups concurrently. That is a latency win only when the calls are genuinely independent. If the second call needs the first result, run them in order; the model will usually express the dependency by waiting for the result before asking again.
tool_choice controls whether tools may be called. auto lets the model decide, none forbids calls, and a named function forces that one. JSON mode is a different tool: response_format set to json_object makes the reply valid JSON without defining a tool, which suits extraction and classification where no function is executed. With strict: true on a function, generation is constrained to the schema you provide.
Use JSON mode when the output is data you will store. Use a tool when the output is an action you will take. Mixing the two in one step produces brittle prompts: the model can either describe a call or make one, and the contract should say which.
When you want managed retries, memory and replayable audit logs, combine function calling with the AI agents API. Otherwise the loop above scales to any number of tools and steps, provided you own the surrounding controls.
Authorisation, timeouts and idempotency
A tool definition is an offer, not a permission. The model proposes a call; your service decides whether the caller may make it. Resolve the tenant and user from the API key and the session, not from an argument the model supplies. A customer_id in the schema is a hint about shape, never a grant of access.
Give every tool a timeout shorter than the request budget, and return the timeout as a tool result instead of letting the whole request fail. For writes, derive an idempotency key from the conversation ID and the tool-call ID, and store it with the result. A retried loop, a duplicated parallel call or a client reconnect can then repeat safely.
- Allow-list the callable set. Never let the model name an arbitrary internal endpoint or SQL statement.
- Scope credentials per tool. A read-only lookup and a refund action should not share a key.
- Cap the loop. Set a maximum number of model turns and a maximum number of tool calls per request.
- Redact the result. Tool output goes back into the model context, so remove secrets, tokens and unnecessary personal data first.
- Log the decision. Record the model, the tool, the parsed arguments, the outcome and the latency, with the conversation ID.
Tool results are also an injection path. A retrieved document or a web response can contain text that looks like an instruction. Keep tool output in a clearly delimited field, tell the model to treat it as data, and never let a tool result change the allow-list.
Testing a tool-calling agent
Test the loop at three levels. Unit-test the function and its validation. Replay recorded conversations against the model and assert on the tool sequence, not only the final text. Then run a small live evaluation with the prompts your users actually send, including the malformed, ambiguous and adversarial ones.
Track four metrics per tool: selection rate, argument-validity rate, execution success rate and time to a final answer. A drop in argument validity usually means a schema description changed or the model tier changed, not that the model became worse overnight. Keep a regression set of conversations and rerun it whenever you edit a definition.
Honest comparison
How we evaluated this: the comparison is against the two realistic alternatives for a team that needs tool use, not against a scored vendor matrix. Criteria are schema compatibility, dispatch control, validation and observability, weighted toward the parts that cause production incidents. No provider was benchmarked, and no latency or accuracy figure was measured for this page.
| Feature | Plugsky | Roll-your-own dispatch | Non-compatible providers |
|---|---|---|---|
| Tool call shape | OpenAI tool_calls | You define the protocol | Varies by vendor |
| Parallel calls | Supported in one response | You dispatch and correlate | Often unavailable |
| JSON mode | response_format with json_object | Prompt engineering plus a parser | Varies |
| Strict schema | strict:true on the function | You validate every argument | Rare |
| Frameworks | Drop-in with OpenAI SDKs and common agent frameworks | Custom glue per framework | Per-vendor SDK |
| Managed agents | Agent runtime with memory and logs | You build retries and logging | Varies |
| Migration cost | Base URL and model name change | Already custom | Rewrite the tool layer |
What we did not verify
- We did not run a load test or measure function-calling latency, throughput or accuracy. Any budget in this guide is arithmetic or a design target, not a benchmark.
- We did not test
tool_choice: "required"on this API. The documented options used here areauto,noneand a named function. - We did not run LangChain, LlamaIndex or the Vercel AI SDK end to end against this endpoint. Compatibility follows from the OpenAI schema; verify your versions.
- We did not review a customer agent’s logs or evaluation set. The metrics above are a suggested method, not observed results.
- We did not verify whether strict mode enforces every JSON Schema keyword. The safe assumption is that it constrains the declared object shape and that your code still validates values.
Frequently asked questions
How many tools can I define?
There is no documented hard limit in the Plugsky API reference, but 5–20 tools is the practical range. Beyond that, selection quality falls and every definition consumes context on every request.
Can I force the model to call a specific tool?
Yes. Set tool_choice to a named function, or use auto and none to control whether tools may be called at all. Named tool_choice is the reliable way to guarantee one call; confirm required-mode support in the current docs before relying on it.
Does streaming work with function calling?
Yes. With stream set to true the response arrives as deltas, and tool-call arguments accumulate across chunks by index. Buffer the arguments until the call is complete, then parse them once.
What happens if my tool throws an error?
Catch it in your code and return a structured error as the tool result. The model sees the error and can retry, ask for a different input or surface the failure to the user. Do not return a stack trace or an internal hostname.
Is the tools shape identical to OpenAI?
Yes. The tools array, tool_choice and tool-call response shape follow the OpenAI schema, so code written for that shape generally works after a base_url change. Test the exact SDK and framework version you run.
Do I need the agents API to use tools?
No. A single tool-calling loop can run in your own code. The agents API adds managed retries, memory and replayable audit logs when you do not want to build that layer.
How do I stop the model calling a tool with bad arguments?
You cannot stop generation, but you can refuse execution. Validate every argument against the same JSON Schema before running the function, reject unknown fields, and return a validation error the model can correct.
Should tool calls be idempotent?
Yes, for anything that writes. Networks retry, loops repeat and a model can request the same call twice. Use an idempotency key derived from the conversation and the tool-call ID, and make the write operation safe to repeat.
Related pages
Build the loop against a real endpoint
Start with two tools and one regression set. Add parallel calls and strict schemas only after the log tells you where the loop fails.
Start free Read the tools APICite this page
Plugsky (2026). “Function Calling API: Tools, Parallel Calls and JSON Mode”. Plugsky. Available at: https://plugsky.com/articles/function-calling-api (last updated 20 November 2026).
By Plugsky Research · Last updated 20 November 2026.
Sources
Primary references below were checked on 20 November 2026. Product claims come from the Plugsky API and plan terms; schema behaviour comes from the published specifications.
- OpenAI: Function calling guide — tools array, tool_choice, parallel calls and the tool-result message shape. Checked 20 November 2026.
- JSON Schema 2020-12 core specification — objects, properties, required and additionalProperties. Checked 20 November 2026.
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — why tool arguments arrive as a JSON string. Checked 20 November 2026.
- Plugsky docs: tools API — endpoint, request shape and supported options. Checked 20 November 2026.
- Plugsky pricing — plan limits and the flat monthly model. Checked 20 November 2026.
- Plugsky status — live component health. Checked 20 November 2026.
Last checked 20 November 2026. Approved product facts live at /facts; canonical plan terms live at /pricing. Legal: Terms and SLA.
Sources and dated checks
Checked 20 November 2026. Primary sources checked 20 November 2026: OpenAI API reference, Anthropic API getting started, Cloudflare Workers AI. Confirm current limits and pricing in the provider console before capacity planning.