Skip to main content
All currently listed Seed, DeepSeek, GLM, and Gemini LLMs support function calling through POST /api/gengen/v1/chat/completions, including SSE streaming. The /v1/chat/completions compatibility alias accepts the same requests.

Function calling

Send OpenAI-compatible tools and tool_choice. The model returns a structured function call; your application executes the function and sends its result in the next request. GENGEN does not execute user-defined functions. This JavaScript example completes one round of function calls and sends all results back. Production applications should continue the loop while calls remain and apply their own execution permissions and maximum iteration count.
A function-only assistant message has content: null and tool_calls. A normally completed function-call turn uses finish_reason: "tool_calls". An interrupted turn can have length or a provider failure reason; check it before executing a call. Return a result for every call, matched by tool_call_id, including multiple calls to the same function. Preserve the complete assistant message, including reasoning fields and provider metadata, when appending it to the conversation. Use tool_choice: "auto" to let the model decide when to call a function. Other selection modes, parallel-call settings, and reasoning options vary by model; check the selected provider’s API reference.

Streaming

Set stream: true to receive Chat Completions SSE chunks. Accumulate choices[0].delta.tool_calls by their zero-based index, retaining each call’s ID, function name, and arguments. Argument fragments must be assembled before parsing JSON or executing a function. Collect the assistant text and any provider metadata as well, following the provider’s replay requirements. Wait for a completed tool-call turn before executing calls. Treat interrupted or failed streams as incomplete; do not execute partial arguments. Return all tool results in the next request using the same conversation loop as above.

Responses API

Models with a Responses endpoint can also return function calls. This API uses flat function declarations and function_call / function_call_output items instead of Chat Completions messages. Follow the selected endpoint’s request, conversation, and streaming contract:

Usage and billing

Each model request is metered, including turns that return only a tool call and streamed completions. Your application executes user-defined functions; their external service costs are separate from model usage. Check the selected model’s pricing before running a multi-turn loop.

Streaming model coverage

All 12 listed LLMs support streaming through Chat Completions. The seven models with a public Responses endpoint also support Responses SSE. Check the endpoint reference for its event lifecycle and completion signals.

Provider guides

Gemini clients that drop extension fields

For Gemini Chat Completions, GENGEN preserves tool signatures and native call IDs when returning tool calls, including streaming responses. Keep each tool_calls[].id and matching tool_call_id unchanged, use the same account and model, and return unchanged function names and arguments. GENGEN can then restore Google metadata if your client discarded the extension fields. Continue preserving those fields when your client supports them. This compatibility support does not recover signatures already lost in an older conversation. If an existing session still reports a missing thought signature, start a new conversation. Responses API clients must continue replaying the original output items and their provider metadata.

OpenAI GPT tools

The four GPT models use native Responses tool declarations and result items. See GPT Responses and tools for a complete execution loop, web search, MCP approvals, computer actions, custom tools, local shell, Apply Patch, encrypted reasoning replay, and supported resource boundaries.