Skip to main content

Tool & Function Calling

Primex forwards tool/function calling to the underlying model in whichever format your client already uses. There are two categories, billed differently.

Function tools (your code runs them)​

Standard OpenAI tools (type function) on /v1/chat/completions and /v1/responses, and Anthropic tools on /v1/messages, pass straight through. The model returns a tool call, your application executes it and sends the result back on the next turn. These add no extra charge beyond the tokens they consume.

{
"model": "YOUR_MODEL",
"messages": [{"role": "user", "content": "What's the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}
}
}]
}

Codex-style custom/grammar tools work on native Responses models. See Responses.

Built-in tools (the provider runs them server-side)​

/v1/responses can request provider-run tools such as web_search. These can incur a separate per-use charge beyond tokens, so Primex only forwards a built-in tool once it is metered end to end; an unmetered built-in tool is rejected with a clear 400 tool_not_available rather than billed silently. Currently web_search is enabled and metered per call; other built-in tools are gated. See Built-in Tools for the current status and per-call rate, and Billing & Credits for how tool usage appears in your ledger.

Remote tools via MCP​

You can attach your own tools through the Model Context Protocol instead of built-in tools. MCP tool traffic bills as ordinary tokens. See MCP Servers.