Key facts
| Definition | Model returns a structured tool call that your application executes |
| Why it matters | Reliable structured output and the mechanism behind agents and integrations |
| How it works | Tools are declared in the request; the model chooses one and fills arguments |
| Execution | Your code runs the function and returns the result; the model never executes it |
| Plugsky support | Live on supported chat models through the OpenAI-compatible API |
| Related patterns | MCP exposes tool servers; function calling invokes them |
| Models | 30+ models behind one API; tool-calling quality varies by model |
| Free tier | Free plan with 2 free AI models, no card required |
TL;DR
- The model proposes tool calls; your code executes them.
- Schemas with clear names and descriptions drive correct selection.
- Validate arguments before execution — output is untrusted input.
- Function calling is the foundation of agents, MCP and structured output.
- Test tool reliability per model before standardizing.
How it works, step by step
- Define each function with a precise name, description and strict JSON schema.
- Send the tool definitions with a chat completion request.
- Detect tool call responses and parse the returned arguments.
- Validate arguments, enforce permissions, then execute with a timeout.
- Return the result as a tool message and let the model produce the final answer.
- Log every call and add regression tests for the tool-selection path.
Try it yourself
Open the function calling schema generator →
How function calling works
A chat request carries tool definitions alongside the messages. The model either replies normally or returns a call naming one tool with JSON arguments. Your application parses the call, validates it and runs the function. The result goes back as a tool message, and the model continues — answering, chaining another call or finishing. This separation is the safety property: the provider's infrastructure never executes your code, so permission enforcement stays with you.
When to use it
- Structured extraction: return fields that match a schema instead of prose.
- Integrations: read a database, create a ticket, send a notification.
- Agents: give a loop the ability to act and observe results.
- Routing: classify intent by which tool the model chooses.
- Math and retrieval: delegate exact work to code or search rather than generation.
If you only need text, skip tools — they add latency and a code path to maintain.
Common mistakes
- Vague tool names and descriptions, causing the wrong tool to be selected.
- Loose schemas that accept anything, so invalid arguments reach execution.
- Executing destructive actions without confirmation or idempotency keys.
- No retry or fallback when a model returns malformed arguments.
- Assuming every model supports tools equally — capability and accuracy vary.
How Plugsky implements it
Plugsky exposes function calling through the OpenAI-compatible chat completions endpoint, so tools are declared in the same request format as OpenAI and existing code works after changing the base URL. Streaming and JSON mode complement it for interactive and schema-constrained flows. Because 30+ models share one API, you can benchmark tool-selection accuracy across models and route production traffic to the one that performs best on your tool set, while keeping fallbacks for errors.
Honest comparison
| Need | Function calling | Plain prompting | JSON mode |
|---|---|---|---|
| Structured output | Schema-guided arguments | Parse free text and hope | Valid JSON, shape not enforced |
| Take actions | Yes, via your code | No | No |
| Tool selection | Model chooses from declared tools | Not applicable | Not applicable |
| Safety control | You validate and execute | Not applicable | Syntax only |
| Best for | Agents and integrations | Simple text tasks | Format-sensitive text |
Frequently asked questions
What is function calling?
A model capability where you declare tools in the request and the model returns a structured call with arguments for your application to execute, then continue the conversation with the result.
Does the model execute my function?
No. The model only proposes the call. Your code validates and executes it, which is where permissions, timeouts and audit logging belong.
How does function calling differ from JSON mode?
JSON mode guarantees syntactically valid JSON but not a particular shape. Function calling guides the model to produce arguments matching your declared schema and selects among tools.
Is function calling the same as MCP?
No. MCP standardizes how tools are exposed to clients; function calling is how the model invokes a tool. They are complementary layers.
Which Plugsky models support function calling?
It is live on supported chat models, and support varies per model. Check the docs and model catalogue for the current matrix.
Can I try function calling for free?
Yes. The free plan includes 2 free AI models with no card, and a 14-day full-access trial covers evaluation with stronger tool-calling models.