Model tool calling

Declare functions, execute tools, and return results with Asale's OpenAI, Anthropic, and Gemini APIs.

このページは未翻訳のため、英語版を表示しています。

The model requests a tool call; your application executes it. A function definition gives the model a name, description, and input schema. It does not give the model direct access to your code or the marketplace. For Asale-managed execution, see the Tool Market API.

The tool calling loop

  1. Get an API key and choose a model that supports function calling and has supply in the model market or GET /v1/models.
  2. Send the tool definitions with the user input. Validate each returned function name, arguments, and permissions before executing it locally or submitting a marketplace run.
  3. Preserve the full assistant message or output items and return a matching result for every call. Keep the tool definitions in follow-up requests. Stop when the model returns an answer without further calls.
APIDeclarationModel returnsSend back
Chat Completionstools[].function.parameterschoices[0].message.tool_callsA role: "tool" message with tool_call_id matching the call id
Responsestype: "function", name, and parameters on each toolfunction_call items in outputOriginal input and prior output items, followed by function_call_output items with matching call_id values
Anthropic Messagestools[].input_schematool_use blocks in contenttool_result blocks in a new user message, with tool_use_id matching each call id
Gemini GenerateContenttools[].functionDeclarations[].parametersJsonSchemafunctionCall parts in candidates[0].content.partsfunctionResponse parts in a new user message, with the function name, the returned id if present, and a response object

Request examples

Open the API section for Google Search and expand OpenAI, Anthropic, or Gemini. The example declares google_search as a model function and submits the model's arguments to POST /v1/tool-runs using the same name. Every market tool eligible for model use has examples generated from its own input schema.

Tool choice, parallel calls, and streaming

  • Start by letting the model decide when to call a function. OpenAI and Anthropic expose tool_choice in their own formats; Gemini uses toolConfig.functionCallingConfig. Supported options vary by model and supplying channel.
  • A single turn can request several tools. Independent calls can run in parallel, but every result must match its corresponding call. Run dependent calls in order, and do not assume every channel supports forcing sequential calls.
  • For streams, assemble the full name, ID, and argument payload before execution. Start with non-streaming requests, and preserve original assistant items rather than reconstructing any opaque fields such as thought signatures.
  • Limit rounds, calls, runtime, and spend. Validate model-generated arguments and treat external results, such as page text or transcripts, as data rather than instructions.