Short answer. Define few, flat tools; set
additionalPropertiesto false and mark every field required; disable parallel calls when you need a predictable budget; and cap the loop. Tool definitions count as input tokens, so a large tool catalogue is a permanent tax on every request.
What the model actually sees
Function definitions are injected into the model's context and billed as input tokens, not as a free configuration layer. A five-tool catalogue at 150 tokens per tool adds 750 tokens to every request, before the user says anything. Add a tool result and a second request, and the same conversation pays for the definitions again.
That is why tool calling is more expensive than it looks on a free tier. A three-step support bot sends the tool schema three times, plus the user message, the assistant's tool call and the tool result. If the history is 2,000 tokens and the tools are 750, the third request is already a 3,000-token prompt.
OpenAI's guide recommends keeping the initial tool set small — fewer than 20 per turn — and loading rarely used tools on demand. Fewer, clearer tools improve accuracy and reduce tokens.
A working tool loop
This example exposes one tool, disables parallel calls for a predictable budget, and stops after three steps. The model returns a tool call, your code executes it, and the result goes back as a tool message with the matching tool_call_id.
import json
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PLUGSKY_API_KEY"],
base_url="https://api.plugsky.com/v1",
)
tools = [{
"type": "function",
"function": {
"name": "get_order",
"description": "Look up an order by its ID.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "Order ID, for example ord_1042.",
},
},
"required": ["order_id"],
"additionalProperties": False,
},
},
}]
def get_order(order_id: str) -> dict:
return {"order_id": order_id, "status": "shipped", "eta": "2026-11-24"}
def run(messages: list[dict], max_steps: int = 3) -> str:
for _ in range(max_steps):
resp = client.chat.completions.create(
model="plugsky-lite",
messages=messages,
tools=tools,
tool_choice="auto",
parallel_tool_calls=False,
max_tokens=500,
)
msg = resp.choices[0].message
messages.append(msg)
if not msg.tool_calls:
return msg.content or ""
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
result = get_order(args["order_id"]) if call.function.name == "get_order" else {"error": "unknown tool"}
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
return "Stopped after max_steps"
Treat model arguments as untrusted input. Parse JSON, validate types, reject unknown fields and never pass the arguments straight into a shell or a database query. If a tool fails, return a short error string to the model rather than raising; the model can often recover, and a stack trace in the tool output wastes tokens.
Schemas that survive smaller models
Strict mode is the difference between "usually valid" and "valid or rejected". OpenAI requires additionalProperties: false on every object and every property listed as required; optional fields use a nullable type.
Not every free model supports strict mode, and support can vary by route. Test it rather than assuming. Send a deliberately ambiguous prompt and inspect whether the response includes strict: false or malformed arguments. If strict mode is unavailable, validate on your side and retry with a repair prompt instead of trusting the first call.
Keep schemas flat. Deep nesting, free-form dictionaries and dozens of optional fields invite hallucinated keys. Use enums, short format descriptions and one purpose per tool.
Token math for tool calling
Assume three tools at 120 tokens each, four steps, and a history that grows by 500 tokens per step. The first request is about 1,400 tokens, the fourth about 2,900, and the task totals roughly 8,500 tokens. At 50,000 tokens per day, that is about five tasks; at 250,000, about twenty-five.
Parallel calls reduce round trips but increase each response and the number of results to feed back. On a free tier, disabling them makes the budget predictable.
| Tool pattern | Tools | Steps | Tokens/task | Free-tier fit |
|---|---|---|---|---|
| Single lookup | 2 | 2 | About 2K | 20+ per day at 50K |
| Order support bot | 5 | 4 | About 8K | About 6 per day at 50K |
| Multi-tool research | 10 | 6 | About 25K | 2 per day at 50K |
| Agent with retries | 15 | 10 | About 60K | Paid plan |
When to pay for tools
Plugsky's free models list tool calling as a capability, but the free plan caps input at 32K, output at 2K, concurrency at two and the day at 250,000 tokens. Paid plans unlock the full catalogue, raise the per-request input cap and add concurrency: Hobby is $8 for 2 million tokens per day and 64K input; Starter is $20 for 5 million and 128K; Builder is $60 with no daily token cap, 256K input and 10 concurrent requests.
Upgrade when a task needs more than 10K tokens, when you run more than 20 tool tasks per day, or when the catalogue grows past what a small model can choose from reliably.
FAQ
Does the OpenAI SDK support tool calling with any compatible API?
Yes, the request shape is the same: tools, tool_choice, then a tool message with tool_call_id. Model support varies, so test whether the model returns structured tool calls, honors strict schemas and handles several tools in one turn.
What is strict mode in function calling?
Strict mode makes the model's arguments conform to the JSON schema instead of best effort. On OpenAI it requires additionalProperties to be false on every object and every property to be listed as required; optional values use a nullable type.
Why does the model call several tools at once?
Parallel tool calling lets the model batch independent calls in one turn. It can reduce latency but increases the response size and the number of results you must send back. Set parallel_tool_calls to false when you need a predictable budget.
Do tool definitions count as tokens?
Yes. Function definitions are injected into the context and billed as input tokens on every request. A large catalogue is a recurring cost, so keep the initial set small and load rarely used tools on demand.
Reviewed 20 November 2026. Primary sources checked 20 November 2026: OpenAI function calling, Groq tool use, Plugsky model catalogue, Plugsky pricing. Free-tier limits are published ceilings, not guarantees; confirm them in the provider console before capacity planning.