Skip to main content
With function calling, the model replies with the function it wants to call and the arguments. Your code runs the function and sends the result back, and the model writes the final answer. LaoZhang API’s OpenAI-compatible endpoints use the same tools format for most text models, so switching models only means changing model.

Which endpoint each model needs

Results from running the same weather function through a full call → result → final answer round trip. GPT-6 and GPT-5.6 models were checked on November 4, 2026, Claude on November 10, and the rest on October 14: Use Chat Completions for models marked ”—”, and whenever you’re unsure. Gemini also supports functionDeclarations in native generateContent; see the Gemini protocol. For tool calling with Claude models, use the Claude protocol at /v1/messages with the base URL https://api.laozhang.ai, as shown in Use tools. If you stay on Chat Completions, the assistant message you send back must have non-empty text in content, or the second turn fails with a 400. See the FAQ entry. OpenAI’s own Chat Completions API doesn’t let GPT-6 or GPT-5.6 use function tools while reasoning. Since November 4, 2026, LaoZhang API handles these requests, so clients that only speak Chat Completions, such as Cline and Cherry Studio, can use GPT-6 with tools. See the GPT-6 Chat Completions tool calling announcement.

Chat Completions example

Install the SDK (python -m pip install openai) and set the LAOZHANG_API_KEY environment variable first.
message.tool_calls in the first reply holds the function name and its arguments as a JSON string. The second request sends back the model’s message plus one tool message per call, and each tool_call_id must match the id of its call. To use another model from the Chat Completions column, change MODEL; nothing else changes. With GPT-6 models:
  • You can pass reasoning_effort, such as "high", in both requests.
  • gpt-6.1-sol and gpt-6-astra don’t accept "none".

Responses example

In Responses, a tool definition drops the nested function object, and results go back as function_call_output items:

Send history back to Responses

Rebuild each function_call item from its call_id, name, and arguments, as the example does. Don’t rely on conversation state stored on the server:
  • Don’t continue with previous_response_id.
  • Don’t paste the first response’s output back into input unchanged.
On LaoZhang API, a model can be served by more than one official route, and two consecutive requests may land on different routes. Both patterns above point to objects stored on the earlier route, so they fail with HTTP 400 when the route changes:
  • The requested item was created under a different Azure OpenAI resource
  • Previous response with id '...' not found
Sending the content without item IDs avoids the problem.

FAQ

Why does gpt-6.1-sol return 400 when I pass tools?

The error reads Function tools with reasoning_effort are not supported. OpenAI doesn’t allow function tools together with reasoning in Chat Completions, and gpt-6.1-sol doesn’t accept reasoning_effort: "none". Since November 4, 2026, LaoZhang API handles these requests, and the same code returns tool_calls. If you still get this 400:
  • Check that the base URL is https://api.laozhang.ai/v1, not OpenAI’s or another provider’s.
  • Send support the time of the error, the model, and the full error message.

Why does Claude return 400 on the second tool-calling turn?

When you call a Claude model through Chat Completions and send back an assistant message whose content is null or an array of content parts, its tool_calls are dropped and the request fails with HTTP 400:
The failed request isn’t charged. Fix it either way:
  • Switch to the Claude protocol at /v1/messages (recommended). Use the base URL https://api.laozhang.ai, a Claude Code-group token, and return results as tool_result blocks as shown in Use tools.
  • Stay on Chat Completions and set that assistant message’s content to a non-empty string, such as "Checking.", leaving tool_calls unchanged.

What if the model returns several function calls at once?

Run each one and send each result back with its own tool_call_id (Chat Completions) or call_id (Responses). Both examples above already loop over every call.

What if the arguments aren’t valid JSON?

Validate them with json.loads. If parsing fails, send the error back as the function result so the model can try again. In Responses, "strict": true on the tool plus "additionalProperties": false in parameters keeps arguments within the schema.

Is function calling billed separately?

No. Tool definitions and function results count as input tokens, and the generated arguments count as output tokens, at the model’s price. Server-side tools such as web search add a per-search fee.
  • Let the model search the web and cite sources: Web search
  • Choosing between Chat Completions and Responses, and GPT-6 parameter rules: OpenAI models
  • Function calling in the native Gemini format: Gemini protocol

References