Skip to main content

APIs

Function calling

Define your own tools and let the model decide when to call them. The proxy forwards the OpenAI tool schema verbatim — nothing Caronte-specific here.

example.ts
import { client } from "./client"; const response = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: "What's the weather in Milan?" }], tools: [ { type: "function", function: { name: "get_weather", description: "Get the current weather for a city.", parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"], }, }, }, ], }); const toolCall = response.choices[0].message.tool_calls?.[0]; console.log(toolCall?.function.name, toolCall?.function.arguments);

Return the tool result

Append the assistant message that emitted the tool_call plus a tool message carrying the result, then re-issue the request.

example.ts
import { client } from "./client"; const result = JSON.stringify({ city: "Milan", temp_c: 21 }); const followup = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [ { role: "user", content: "What's the weather in Milan?" }, /* assistant tool_call message from previous response */ { role: "tool", tool_call_id: "<call_id from previous response>", content: result, }, ], }); console.log(followup.choices[0].message.content);