Short answer. Plugsky function calling uses the OpenAI tools array: send JSON-Schema function definitions in
tools, receive a structuredtool_callspayload, execute the function yourself, then return arole=toolmessage with the result. The docs state that streaming and parallel tool calls are supported. It runs onPOST https://api.plugsky.com/v1/chat/completions, is documented at the function-calling section of the API docs, and is locked on the Free plan.
What function calling does
A normal chat completion returns text. A function-calling completion can return a machine-readable request instead: a tool name and a JSON argument object. The model does not execute anything. It proposes a call, your application decides whether to run it, and the result is appended to the conversation so the model can continue with facts rather than guesses.
That division is the safety property. The model can propose refund_order, but only your code can issue the refund. It also means the reliability of the feature depends on your dispatcher: schema quality, argument parsing, timeouts, idempotency and loop limits are application responsibilities. Plugsky supplies the protocol and the model; it does not run your side effects.
The shape is deliberately OpenAI-compatible. A tools array, a tool_calls response, tool_choice and role=tool results carry over from existing OpenAI code, which is why the same loop works with the official SDKs and with frameworks that speak the OpenAI tool format. The exact request fields are listed in the function-calling section of the API docs.
How the loop works
The loop has five moves. Most production bugs come from skipping the last two.
- Send the conversation plus a
toolsarray. Each tool has a name, a description and a JSON-Schema parameter object. - Read the response. If it contains
tool_calls, parse each call's name and arguments. If it contains ordinary text, the model chose not to use a tool; stop. - Execute the requested function in your system, with your authentication, timeouts and authorization checks.
- Append a
role=toolmessage for every call, carrying the matchingtool_call_idand the result as a string. - Call the model again so it can use the results, and repeat until it answers without a tool call or your iteration budget runs out.
Parallel calls make step four stricter. If the model returns three calls, you owe it three results. A missing result, a mismatched ID or a result attached to the wrong call will produce a confused follow-up or a request error.
Exact tool definition
Start with one narrow, read-only tool. Broad tools with mode switches are harder for the model to choose correctly and harder for you to authorize. The definition below follows the JSON-Schema object shape the docs describe.
tools = [
{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Return the current status of one order. Read-only.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "Order ID, for example ord_1042."
},
"include_lines": {
"type": "boolean",
"description": "Include line items in the result."
}
},
"required": ["order_id"]
}
}
}
]
Write descriptions for the model, not for a human reviewer. Say when to use the tool, when not to, what the ID looks like and whether the call is read-only. Put enums on fields that accept a fixed set, and keep required fields to the minimum the function truly needs.
The execution loop in Python
The example uses the OpenAI SDK against Plugsky. The base URL is https://api.plugsky.com/v1; Plugsky's public docs also show https://plugsky.com/v1, so pick one host and keep it consistent.
import json
from openai import OpenAI
client = OpenAI(
api_key="sk-live-...",
base_url="https://api.plugsky.com/v1",
)
messages = [{"role": "user", "content": "Where is order ord_1042?"}]
first = client.chat.completions.create(
model="plugsky-pro",
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)
result = {"order_id": args["order_id"], "status": "in_transit"}
except (json.JSONDecodeError, KeyError) as exc:
result = {"error": f"invalid arguments: {exc}"}
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
final = client.chat.completions.create(
model="plugsky-pro",
messages=messages,
tools=tools,
)
print(final.choices[0].message.content)
else:
print(message.content)
Three details are doing real work. The try/except keeps a malformed argument string from crashing the request. The result is JSON-encoded text, because the tool message carries a string. And the second call includes the same tools array, so the model can request another tool if the first result is insufficient.
tool_choice, JSON mode and streaming
These are separate controls and should not be confused. tool_choice decides whether the model may call a tool and whether a specific tool is forced. response_format asks for JSON output from the model itself. Streaming changes how the response arrives, not what the model is allowed to do.
- Automatic choice.
tool_choice="auto"lets the model decide between text and one or more tools. This is the right default for assistants that sometimes answer directly. - Forced choice. The same parameter can require a named function when a workflow step must produce a tool call. Forcing a tool on a prompt that lacks the required inputs invites invented arguments; use it only when the inputs are guaranteed.
- JSON mode.
response_formatis for structured text you want to parse yourself. It does not execute anything and does not replace a tool schema. - Streaming. With
stream: true, the response arrives as server-sent events. Tool-call arguments can arrive in fragments, so assemble the full call before parsing. The docs list streaming as supported for function calling. - Parallel calls. A single response can carry multiple tool calls. Dispatch them concurrently only if your downstream systems tolerate it, and collect every result before the next model turn.
Limits that shape a tool design
Plugsky does not publish a maximum number of tools per request. The binding constraint is context: every tool definition is sent with every turn, so a large catalogue consumes room that history and retrieved documents need. The main text models serve 262,144 tokens of context; the vision models serve 131,072; translation and the GPU Share route serve 32,768. Tool definitions compete with all of it.
Plan capacity applies as it does to any chat request. Hobby allows 4 concurrent requests and 120 RPM; Starter 6 and 240; Builder 10 and 600; Scale 16 and 1,200. Hobby and Starter also have daily request and token caps. A tool loop multiplies requests: one user question can become three or four completions, so measure the loop, not the single call.
Plan eligibility is the other hard boundary. The Free plan is documented as excluding Tools and Connectors, the function-calling surface. Tool use therefore requires a paid workspace. That is a commercial gate, not a transient error.
| Control | Documented behaviour | Production consequence |
|---|---|---|
tools | Array of JSON-Schema function definitions on chat completions | Every definition consumes context on every turn; keep the set narrow |
tool_choice | Optional parameter controlling tool selection | Use auto by default; force a named tool only when inputs are guaranteed |
| Parallel calls | Supported; one response can contain several calls | Return one result per tool_call_id before the next model turn |
| Streaming | Supported with stream: true | Assemble fragmented arguments before parsing or executing |
response_format | JSON mode for model output | Separate from tools; use it when you want structured text, not an action |
| Tool result | role=tool message with the matching call ID | The result is a string; JSON-encode objects and cap the payload size |
| Plan access | Tools and Connectors are locked on Free | A paid workspace is required; retrying will not change the gate |
| Context | 262,144 tokens on main text models; lower on specialist models | Tools, history and retrieved documents share one budget |
Failure modes and fixes
Tool use fails in predictable ways. Instrument the loop so each failure is visible before a user reports it.
- The model never calls a tool. The description is vague, the prompt does not require a lookup, or
tool_choiceis set to auto on a question the model thinks it can answer. Tighten the description and test with a prompt that cannot be answered without the tool. - Arguments are invalid JSON. Parse defensively and return the parse error as a tool result. Do not execute a partial object. If the same malformed call repeats, simplify the schema.
- The model calls a tool that does not exist. Your dispatcher must reject unknown names and return a useful error instead of raising. Log the name; repeated hallucinated tools usually mean the tool list and the prompt disagree.
- A tool result is too large. Long API responses, HTML pages and database dumps can trigger a 413 or consume the context needed for the answer. Truncate, summarise or paginate before appending the result.
- The loop never ends. Cap iterations and total tokens, and detect repeated identical calls. A model that asks for the same lookup three times needs a different result or a stop, not a fourth attempt.
- A write is retried. A 429 or 503 in the middle of a loop can replay a side effect. Put an idempotency key on the downstream write, not only on the model request.
- Plan quota is exhausted. A 429 carries
Retry-After; honour it. A 402 means a project budget cap, which is a finance decision rather than a transient error.
When not to use function calling
Function calling is not the default for every structured task. Four cases are better served by something simpler.
- You only need structured text. Extraction, classification and form-filling are better handled with JSON mode. A tool that does nothing but echo a schema adds a round trip.
- The operation is deterministic. If the answer is a calculation or a database lookup with known inputs, do it in code before the model call. Do not ask a model to decide whether to add two numbers.
- You need a managed loop with an audit trail. The agents API supplies a run, a step budget, per-agent memory, an approval gate and a step trace. Running that yourself is possible, but it is work you will maintain.
- The action is destructive and unapproved. A tool call is still an action. Put a human approval gate in front of writes, sends and spends rather than trusting a prompt instruction.
What the docs do not pin down
Three claims circulate in tutorials that the public docs do not clearly state. Treat them as test items, not specifications.
- Server-side schema validation. A companion article says Plugsky validates arguments against your schema before returning the call. The API docs describe the tools array and the returned payload, not a validation guarantee. Validate in your dispatcher.
- Strict schema mode. The docs document
tools,tool_choiceandresponse_format. They do not document a strict flag that forbids extra fields. If exact shape matters, validate after parsing. - A maximum tool count. No number is published. Context and selection quality are the real limits, and both are workload-specific.
Frequently asked questions
What is function calling on Plugsky?
Function calling lets the model return a structured request to run one of your functions instead of returning prose. You send a tools array with JSON-Schema definitions on /v1/chat/completions, the model returns a tool_calls payload, your code executes it and sends the result back. Plugsky documents streaming and parallel tool calls on the same endpoint.
Which models support function calling?
Function calling is documented on the chat completions endpoint, which serves the 39 public model IDs. The docs do not publish a model-by-model tools matrix, so test the exact model you pin. Tool definitions consume context, so a small-context model gives you less room for tools than a 262,144-token text model.
Do parallel tool calls work?
Yes. The docs state that streaming and parallel tool calls are supported. A single response can contain more than one tool call, and your dispatcher must execute each one, append a result for every tool_call_id and then continue the conversation once all results are present.
Does function calling work with streaming?
Yes. The docs list streaming among the supported function-calling behaviours on chat completions. Buffer the tool-call fragments until the stream completes, then parse the assembled arguments; do not execute a partially received JSON string.
Do I need the agents API to use tools?
No. You can run the tool loop in your own code with chat completions. The agents API adds a managed run, a step budget, per-agent memory, an approval gate and a replayable step trace. Use it when those controls are worth more than the flexibility of your own orchestrator.
Why are tools unavailable on the Free plan?
Plugsky documents Tools and Connectors, the function-calling surface, as locked until upgrade on the Free plan. A paid workspace is required. The gate is a plan boundary rather than a rate limit, so retrying the same request will not clear it.
Related pages
Define the tool, then bound the loop
Keep the schema narrow, cap iterations, validate every argument and return one result per call. Paid plans include the full 39-model catalogue.
Sources
Platform behaviour is cited from Plugsky’s documentation, checked on 20 November 2026. The external references define the schema and tool-call conventions the API follows.
- Plugsky API docs, function calling and tools:
plugsky.com/docs#tools-api— tools array, tool_calls, parallel calls and streaming. Checked 20 November 2026. - Plugsky API docs, agents and tools:
plugsky.com/docs/agents— managed runs, step budgets, memory and approval gates. Checked 20 November 2026. - OpenAI function calling guide — the tools, tool_choice and tool-result conventions the compatible shape follows. Checked 20 November 2026.
- JSON Schema: object reference — properties, required fields and nested objects. Checked 20 November 2026.
Last checked 20 November 2026. Function calling is documented on chat completions; model behaviour and schema adherence vary by prompt and model, so test the exact pair you deploy. The API host in this page is https://api.plugsky.com/v1; the docs also show https://plugsky.com/v1 as an alias.