Prompt example extracted from OpenRouter Docs.
OpenRouter
,
tool
}
from
'@openrouter/agent'
;
import
{
z
}
from
'zod'
;
const
openrouter
=
new
OpenRouter
({
apiKey:
process
.
env
.
OPENROUTER_API_KEY
,
});
const
weatherTool
=
tool
({
name:
'get_weather'
,
description:
'Get the current weather for a location'
,
inputSchema:
z
.
object
({
location:
z
.
string
().
describe
(
'City name'
),
}),
execute
:
async
({
location
})
=>
{
return
{
temperature:
72
,
condition:
'sunny'
,
location
};
},
});
const
result
=
openrouter
.
callModel
({
model:
'~anthropic/claude-sonnet-latest'
,
messages:
[
{
role:
'user'
,
content:
'What is the weather in San Francisco?'
},
],
tools:
[
weatherTool
],
});
const
text
=
await
result
.
getText
();
console
.
log
(
text
);