Developer + API

How does OpenAI-compatible function calling work on Plugsky?

Function calling turns a model into an agent: the model returns a structured request to call one of your functions, your code runs it, and the result goes back into the conversation. Plugsky implements the OpenAI tools shape, so LangChain, LlamaIndex, the Vercel AI SDK and the official OpenAI libraries work without modification, including parallel calls, tool_choice and strict schemas.

Key facts

ShapeOpenAI-compatible tools array and tool_calls response
LoopThe model returns tool calls, your code executes them and returns role=tool results
Parallel callsMultiple tool calls in one response, dispatched concurrently
tool_choiceForce a named tool, auto, or none
JSON moderesponse_format set to json_object for guaranteed JSON output
Strict schemasstrict:true forces the exact schema with no extra fields
FrameworksLangChain, LlamaIndex, Vercel AI SDK and the OpenAI SDKs
Product statusLive

TL;DR

  • Tools are JSON Schema objects with descriptions and required fields.
  • Parallel tool calls and tool_choice are supported with the OpenAI shape.
  • Strict mode forces the model to match your schema exactly.
  • Count on 5-20 tools in practice; more makes selection unreliable.
  • Combine with the agents API when you want retries, memory and audit logs.

How it works, step by step

  1. Define tools as JSON Schema objects with clear field descriptions.
  2. Send them in the tools array on /v1/chat/completions.
  3. Detect tool_calls in the response and parse the JSON arguments.
  4. Execute your function and append a role=tool message with the result.
  5. Loop until the model returns a normal message with no tool calls.
  6. Add tool_choice or strict mode where you need determinism.
  7. Return tool errors as payloads the model can see and react to.
1Define tools asJSON Schema objectswith clear field2Send them in thetools array on/v1/chat/completions.3Detect tool_callsin the response andparse the JSON4Execute yourfunction and appenda role=tool message5Loop until themodel returns anormal message with6Add tool_choice orstrict mode whereyou need

Try it yourself

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.

Because the shape matches OpenAI, the same loop works with the official SDKs and with frameworks such as LangChain, LlamaIndex and the Vercel AI SDK. Plugsky validates arguments against your schema before returning the call to your code.

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. Descriptions on every field matter because the model uses them to decide what to call and when.

Keep the tool count deliberate. The live guidance is that 5-20 tools is the sweet spot; beyond that the model struggles to choose correctly, and every definition consumes context on each request.

The same platform exposes 30+ models, so you can run cheap models for routine tool calls and stronger models for planning steps.

Parallel calls, JSON mode and agents

Plugsky supports parallel function calls, so the model can return several tool calls in one response and your code can dispatch them concurrently. tool_choice lets you force a specific tool, while response_format set to json_object guarantees JSON output. With strict: true on a tool, the model must use exactly the schema you provide.

When you want managed retries, memory and audit logs, combine function calling with the AI agents API. Otherwise the loop above scales to any number of tools and steps.

Honest comparison

FeaturePlugskyRoll-your-own dispatchNon-compatible providers
Tool call shapeOpenAI tool_callsYou define the protocolVaries
Parallel callsSupportedYou dispatchRare
JSON moderesponse_format json_objectPrompt engineeringVaries
Strict schemastrict:true supportedYou validateRare
FrameworksDrop-in with OpenAI SDKsCustom gluePer-vendor SDK
Managed agentsAgent runtime with memory and logsYou build retries and loggingVaries

Frequently asked questions

How many tools can I define?

There is no hard limit, but 5-20 tools is the practical sweet spot. More than that and the model struggles to pick the right one.

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.

Does streaming work with function calling?

Yes. With stream set to true the model streams the text portion and emits the tool call when it is ready.

What happens if my tool throws an error?

Catch it in your code and return an error message as the tool result. The model sees the error and can retry or surface it to the user.

Is the tools shape identical to OpenAI?

Yes. The tools array, tool_choice and tool call response shape match, so existing function-calling code works after a base_url change.

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.

Cite this page

Plugsky (2026). “Function Calling API: OpenAI Tool Use”. Plugsky. Available at: https://plugsky.com/articles/function-calling-api (last updated 2026-09-25).