Tools and streaming
Authoritative guidance on tool calling and streaming for the official OpenAI- and Anthropic-compatible endpoints exposed by KushRouter.
- OpenAI Chat Completions:
POST /api/openai/v1/chat/completions - OpenAI Responses:
POST /api/openai/v1/responses - Anthropic Messages:
POST /api/anthropic/v1/messages
This guide intentionally follows the official OpenAI and Anthropic event styles.
OpenAI Chat Completions
- Tools declared via
tools: [{ type: 'function', function: { name, description?, parameters? } }]. - Argument deltas stream at
choices[0].delta.tool_calls[].function.arguments. - Final-arguments fallback is emitted for providers that only send complete args at stop.
stream_options.include_usage: trueemits a final usage-only chunk before[DONE].
OpenAI Responses
- Tools declared with the Chat-compatible
toolsarray. - Non-streaming tool calls return
status: "requires_action"withsubmit_tool_outputs. - Streaming emits
response.function_call_arguments.deltaand.done. - Terminal:
response.requires_actionorresponse.completed; usage may be included.
Anthropic Messages
- Tools declared via
tools/tool_choicein Anthropic syntax. - Streaming emits Claude-style SSE events including tool use blocks and
input_json_delta. - Usage fields include
cache_creation_input_tokens,cache_read_input_tokens,input_tokens, andoutput_tokens.
Anthropic web tools support
Anthropic web tools are not supported on this endpoint. See the note here; for background, refer to this page’s guidance and event references.
Best practices
- Validate and sanitize tool outputs, treat arguments as untrusted JSON, implement idempotency/timeouts, prefer streaming for low-latency UX.