AI Concepts

What is function calling?

Function calling lets a model return structured tool calls instead of prose. You send tool schemas with the request; the model decides which function to invoke and with which arguments; your code executes it and returns the result for the model to continue. It powers agents, integrations and reliable structured output. Plugsky supports function calling on live chat models.

Key facts

DefinitionModel returns a structured tool call that your application executes
Why it mattersReliable structured output and the mechanism behind agents and integrations
How it worksTools are declared in the request; the model chooses one and fills arguments
ExecutionYour code runs the function and returns the result; the model never executes it
Plugsky supportLive on supported chat models through the OpenAI-compatible API
Related patternsMCP exposes tool servers; function calling invokes them
Models30+ models behind one API; tool-calling quality varies by model
Free tierFree 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

  1. Define each function with a precise name, description and strict JSON schema.
  2. Send the tool definitions with a chat completion request.
  3. Detect tool call responses and parse the returned arguments.
  4. Validate arguments, enforce permissions, then execute with a timeout.
  5. Return the result as a tool message and let the model produce the final answer.
  6. Log every call and add regression tests for the tool-selection path.
1Define eachfunction with aprecise name,2Send the tooldefinitions with achat completion3Detect tool callresponses and parsethe returned4Validate arguments,enforcepermissions, then5Return the resultas a tool messageand let the model6Log every call andadd regressiontests for the

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

NeedFunction callingPlain promptingJSON mode
Structured outputSchema-guided argumentsParse free text and hopeValid JSON, shape not enforced
Take actionsYes, via your codeNoNo
Tool selectionModel chooses from declared toolsNot applicableNot applicable
Safety controlYou validate and executeNot applicableSyntax only
Best forAgents and integrationsSimple text tasksFormat-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.