​
Request Body Examples
Tool calling with OpenRouter involves three key steps. Here are the essential request body formats for each step:
​
Step 1: Inference Request with Tools
{
"model"
:
"google/gemini-3-flash-preview"
,
"messages"
: [
{
"role"
:
"user"
,
"content"
:
"What are the titles of some James Joyce books?"
}
],
"tools"
: [
{
"type"
:
"function"
,
"function"
: {
"name"
:
"search_gutenberg_books"
,
"description"
:
"Search for books in the Project Gutenberg library"
,
"parameters"
: {
"type"
:
"object"
,
"properties"
: {
"search_terms"
: {
"type"
:
"array"
,
"items"
: {
"type"
:
"string"
},
"description"
:
"List of search terms to find books"
}
},
"required"
: [
"search_terms"
]
}
}
}
]
}
See all 29 lines
​
Step 2: Tool Execution (Client-Side)
