Skip to content
Numes

Features

Hosted tools

Use web search, fetching, code execution and other tools that run on the provider's side, with per-tool configuration and per-call billing.

On this page

Hosted tools run at the provider instead of in your code. You declare them in tools next to any function tools; the provider runs them while generating, and you receive the outcome: the final text, citations and inline files. Queries, generated code, call traces, resource identifiers and credentials are never returned.

Hosted tools are a fixed, versioned set. A request routes only to endpoints that support every tool it asks for, and each tool call is billed at the endpoint's published per-call rate.

Request a hosted tool

Add the tool to tools. The simplest form names a common tool type:

curl -X POST "https://api.numes.ai/api/v1/chat/completions" \  -H "Authorization: Bearer $NUMES_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-6-luna",    "messages": [      {        "role": "user",        "content": "What changed in the latest stable release of SQLite? Cite your sources."      }    ],    "tools": [      {        "type": "web_search"      }    ],    "max_tool_calls": 3  }'

There are two forms:

FormExampleRoutes to
Common type{"type": "web_search"}Any endpoint that supports one of the tool IDs behind that type
Namespaced ID{"type": "hosted", "id": "openrouter.web_search@1"}Only endpoints that support that exact tool ID

Use a common type when any implementation will do. Use a namespaced ID when you need a specific implementation or its configuration keys: common types accept a smaller set of configuration keys, and several accept none.

Hosted tool

typestringRequired

A common tool type from the table below, or hosted for the namespaced form.

idstring

Required when type is hosted: one of the namespaced IDs. Not allowed on common types.

configurationobject

Tool-specific settings. Only the keys listed for that tool are accepted. At most 16 properties and 32 KiB. See Configuration reference.

resource_aliasesstring[]

Up to 32 unique names of provider-configured resources. See Resource aliases.

Each tool may appear once per request. Hosted tools cannot take function, parameters or strict.

Common tool types

A common type resolves to whichever of its namespaced IDs the selected endpoint supports.

Common typeResolves toConfiguration keys
web_searchopenrouter.web_search@1, openai.web_search@1, anthropic.web_search@1, google.search@1None
web_fetchopenrouter.web_fetch@1, anthropic.web_fetch@1None
datetimeopenrouter.datetime@1timezone
image_generationopenrouter.image_generation@1, openai.image_generation@1Image generation keys
code_executionopenai.code_interpreter@1, anthropic.code_execution@1, google.code_execution@1None
file_searchopenai.file_search@1, google.file_search@1None
shellopenai.shell@1None
mcpopenai.mcp@1, anthropic.mcp@1None
tool_searchopenai.tool_search@1, anthropic.tool_search@1None
skillsopenai.skills@1None
mapsgoogle.maps@1None
url_contextgoogle.url_context@1None
advisoropenrouter.advisor@1, anthropic.advisor@1model, max_uses, caching
apply_patchopenrouter.apply_patch@1None
fusionopenrouter.fusion@1models
subagentopenrouter.subagent@1model, max_turns

"None" means the tool accepts an omitted, null or empty configuration only. To configure web search, for example, use a namespaced ID such as openrouter.web_search@1.

Namespaced IDs

The namespaced form is {"type": "hosted", "id": "<id>"}. New tools arrive only with a new versioned ID.

IDConfiguration keys
openrouter.web_search@1max_results, search_prompt, engine
openrouter.web_fetch@1max_uses, max_content_tokens, allowed_domains, blocked_domains, citations
openrouter.datetime@1timezone
openrouter.image_generation@1Image generation keys
openrouter.apply_patch@1None
openrouter.fusion@1models
openrouter.advisor@1model, max_uses, caching
openrouter.subagent@1model, max_turns
openai.web_search@1external_web_access, filters, search_context_size, user_location
openai.file_search@1max_num_results, top_k, metadata_filter
openai.code_interpreter@1None
openai.image_generation@1Image generation keys
openai.shell@1None
openai.mcp@1server_label, server_description, allowed_tools
openai.connectors@1server_label, server_description, allowed_tools
openai.tool_search@1execution, description
openai.skills@1None
anthropic.web_search@1max_uses, allowed_domains, blocked_domains, user_location
anthropic.web_fetch@1max_uses, max_content_tokens, allowed_domains, blocked_domains, citations
anthropic.code_execution@1None
anthropic.advisor@1model, max_uses, caching
anthropic.tool_search@1None
anthropic.mcp@1server_label, server_description, allowed_tools
google.search@1search_types, time_range_filter
google.maps@1None
google.url_context@1None
google.file_search@1max_num_results, top_k, metadata_filter
google.code_execution@1None

openai.connectors@1 has no common type; request it by ID. An accepted ID doesn't mean any endpoint offers the tool: check discovery first.

Configure a tool

This request restricts a fetch tool to one domain and asks for citations:

curl -X POST "https://api.numes.ai/api/v1/chat/completions" \  -H "Authorization: Bearer $NUMES_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-6-luna",    "messages": [      {        "role": "user",        "content": "Summarize the changelog at https://docs.example.com/changes"      }    ],    "tools": [      {        "type": "hosted",        "id": "anthropic.web_fetch@1",        "configuration": {          "max_uses": 2,          "allowed_domains": [            "docs.example.com"          ],          "citations": {            "enabled": true          }        }      }    ]  }'

A key the tool doesn't accept, a value outside its range or an unknown key inside a nested object fails with 400 invalid_request; configuration is never silently dropped. Configuration never carries credentials or upstream resource identifiers; use resource aliases for resources.

Configuration reference

Each key is accepted only by the tools listed for it in the tables above.

Search and fetch

max_resultsinteger

1–20. Results per search (openrouter.web_search@1).

search_promptstring

1–4096 bytes. Guidance for the search step (openrouter.web_search@1).

enginestring

auto, native or exa (openrouter.web_search@1).

max_usesinteger

1–20. Maximum uses of the tool in one response.

max_content_tokensinteger

1–1,000,000. Limit on fetched content.

allowed_domainsstring[]

Up to 100 unique domains, each 1–253 bytes.

blocked_domainsstring[]

Up to 100 unique domains, each 1–253 bytes.

citationsobject

{"enabled": boolean}.

external_web_accessboolean

Allow live web access (openai.web_search@1).

filtersobject

{"allowed_domains": string[]} with the same limits as above (openai.web_search@1).

search_context_sizestring

low, medium or high (openai.web_search@1).

user_locationobject

Approximate location to localize results.

Show child attributes
typestring

approximate.

countrystring

Two-letter country code.

citystring

1–128 bytes.

regionstring

1–128 bytes.

timezonestring

1–128 bytes.

search_typesobject

{"web_search": {}, "image_search": {}}; include the types to enable (google.search@1).

time_range_filterobject

start_time and end_time strings, 1–128 bytes each (google.search@1).

Files and connected services

max_num_resultsinteger

1–100.

top_kinteger

1–100.

metadata_filterstring

1–4096 bytes.

server_labelstring

1–128 bytes.

server_descriptionstring

1–4096 bytes.

allowed_toolsstring[]

Up to 256 unique names, each 1–128 bytes.

executionstring

server (openai.tool_search@1).

descriptionstring

1–4096 bytes (openai.tool_search@1).

Models and agents

modelstring

1–256 bytes. The model the tool uses (advisor, subagent and their IDs).

max_usesinteger

1–20 (advisor and its IDs).

cachingobject

type ephemeral and ttl 5m or 1h (advisor and its IDs).

max_turnsinteger

1–64 (subagent, openrouter.subagent@1).

modelsstring[]

Up to 16 unique model names, each 1–256 bytes (fusion, openrouter.fusion@1).

timezonestring

1–128 bytes (datetime, openrouter.datetime@1).

Image generation

Accepted by image_generation, openrouter.image_generation@1 and openai.image_generation@1.

backgroundstring

auto, opaque or transparent.

input_fidelitystring

low or high.

modelstring

1–256 bytes.

moderationstring

auto.

output_compressioninteger

0–100.

output_formatstring

png, jpeg or webp.

partial_imagesinteger

0–3.

qualitystring

auto, low, medium or high.

sizestring

auto, 1024x1024, 1024x1536 or 1536x1024.

Resource aliases

Some tools work on resources that belong to the provider: file and vector stores for file_search, MCP servers for mcp, and connectors for openai.connectors@1. You refer to such a resource by an alias, a short name the provider gave you for it:

JSON
{  "type": "hosted",  "id": "openai.file_search@1",  "configuration": { "max_num_results": 8 },  "resource_aliases": ["product-manuals"]}
  • Each alias matches ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$; up to 32 unique aliases per tool.

  • The resource ID and any credential stay with the provider and never appear in your request, the response or usage.

  • Aliases belong to one provider. Use them with an endpoint whose provider gave you the alias, and pin that endpoint with provider.only.

Discover support

Models and endpoints list the namespaced IDs they support in supported_hosted_tools; the field is omitted when there are none. A model row describes one representative offer, so check the endpoints of the model for the full picture:

curl "https://api.numes.ai/api/v1/models/openai/gpt-6-luna/endpoints" \  -H "Authorization: Bearer $NUMES_API_KEY"
Endpoint excerpt
{  "name": "Example Provider: primary",  "tag": "example-provider/primary",  "supported_parameters": ["max_tokens", "reasoning", "tools", "tool_choice"],  "supported_hosted_tools": ["openrouter.web_search@1", "openrouter.web_fetch@1", "openrouter.datetime@1"]}

An endpoint that supports openrouter.web_search@1 also serves requests for the common web_search type. The catalogue can filter models by hosted tool and shows each endpoint's per-call rates.

Routing requirements

A request with hosted tools routes only to endpoints that support tool calling and every requested hosted tool; if none qualifies, it fails with 503 provider_unavailable. A tool is never dropped to find an endpoint.

  • tool_choice: "none" removes all tools from the request, hosted ones included, and removes the requirement.

  • A named tool_choice sends only that function tool, so hosted tools are unavailable in that request.

  • tool_choice: "required" is satisfied only by a function call returned to you. Hosted tool executions are not returned as calls and do not count.

  • Function tools can be combined with hosted tools. Only function calls come back in tool_calls; see Tool calling.

Results

Hosted tool output arrives in the assistant message:

Response excerpt
{  "choices": [    {      "index": 0,      "finish_reason": "stop",      "message": {        "role": "assistant",        "content": "The latest release adds new JSON functions and improves query planning [1].",        "annotations": [          {            "type": "url_citation",            "url": "https://docs.example.com/changes",            "title": "Release History",            "start_index": 71,            "end_index": 74          }        ]      }    }  ],  "usage": {    "prompt_tokens": 1240,    "completion_tokens": 96,    "total_tokens": 1336,    "hosted_tool_usage": { "openrouter.web_search@1": 1 },    "cost": 0.004375,    "cost_details": { "upstream_inference_cost": 0.004375 }  }}

Message fields

contentstring | null

The answer, informed by the tool results.

annotationsobject[]

Citations. Up to 256 per response.

Show child attributes
typestring

url_citation or file_citation.

urlstring

Cited URL, for url_citation.

titlestring

Title of the cited source.

filenamestring

Cited file, for file_citation.

start_indexinteger

Start of the cited span in content.

end_indexinteger

End of the cited span in content.

artifactsobject[]

Files produced by a tool, such as a generated image or a file from code execution. At most max_tool_calls per response.

Show child attributes
typestring

image, audio or file, derived from the media type.

filenamestring

File name.

media_typestring

MIME type.

datastring

Base64 content.

In a stream, annotations and artifacts arrive as delta.annotations and delta.artifacts. See Streaming. Hosted tool executions never appear in tool_calls.

Usage and billing

Each hosted tool is billed per call, as a SKU named by its namespaced ID. The reported quantity appears in usage.hosted_tool_usage (only when non-zero) and on GET /generation:

JSON
"hosted_tool_usage": { "openrouter.web_search@1": 2, "openrouter.web_fetch@1": 1 }
  • The charge is the quantity times the endpoint's per-call rate for that SKU, plus the platform fee, in your key's billing currency. An endpoint serves a hosted tool only if it publishes a per-call rate for it.

  • Hosted-tool charges are based on the usage the platform accepts from the provider's response. Quantities are whole calls, bounded by max_tool_calls.

  • While the request runs, funds are held for up to max_tool_calls calls of each requested tool (128 when you omit it). You're charged only for actual usage, but a lower max_tool_calls reduces the hold and the chance of a 402. See Credits.

Errors

Statuserror_typeCause
400invalid_requestUnknown type or ID, id on a common type, duplicate tool, disallowed or out-of-range configuration key, invalid or duplicate resource alias.
402insufficient_creditsThe balance or key budget can't cover the hold, including max_tool_calls hosted calls.
503provider_unavailableNo eligible endpoint supports tool calling and every requested hosted tool.
502provider_unavailableThe endpoint couldn't run the request, for example because it doesn't have the resource alias.

Best practices

  • Start with a common type and switch to a namespaced ID only when you need its configuration or a specific implementation.

  • Set max_tool_calls to the number of calls a request needs. It bounds cost and the hold on your balance.

  • Ask for citations in the prompt and render annotations next to the answer so readers can verify sources.

  • Check discovery before relying on a tool. An accepted ID doesn't mean any endpoint serves it.

  • Pin endpoints when you use resource aliases, since aliases exist only on the provider that configured them.

Next steps