API capabilities

Call your application tools

Send OpenAI-style function definitions and execute requested tools in your own application loop.

Define a tool

Use the OpenAI-compatible tools and tool_choice fields. A tool definition describes a function available in your application; Gonka24 does not execute that function for you.

typescript
const response = await client.chat.completions.create({
  model: "<model-id-from-/v1/models>",
  messages: [{ role: "user", content: "What is the weather in Warsaw?" }],
  tools: [{
    type: "function",
    function: {
      name: "get_weather",
      description: "Get the weather for a city",
      parameters: {
        type: "object",
        properties: { city: { type: "string" } },
        required: ["city"],
      },
    },
  }],
  tool_choice: "auto",
});

const toolCalls = response.choices[0]?.message.tool_calls ?? [];

Complete the loop

  1. Read message.tool_calls from the assistant response.
  2. Validate the function name and JSON arguments against your own allowlist and schema.
  3. Execute the function in your application, append a tool result message, then send the conversation back to the model.

Safety and compatibility

Tool behavior depends on the selected model and route. Start with an isolated read-only tool, validate the non-streaming flow, then validate streamed tool-call arguments separately. Tool calling is not an MCP endpoint: use an MCP client or server separately when your architecture needs MCP.