Messages, Responses, and ChatCompletions. See Web search for runnable requests and outputs.
Request fields
x-baseten-server-tools
Include this header on every request that uses server-side tool execution:
baseten__* selector as an unknown tool type.
tools
Select a tool for Baseten to execute server-side with an object that contains its type:
baseten__<provider>__<tool> in the request’s tools array. Extra fields on a selector return 400.
Tool catalog
Search tools discover pages. Fetch tools retrieve content from known URLs. Give the model both when it should discover sources and then read selected pages.
The advanced Exa search schema adds domain filters, subpage crawling, and a summary option to the basic search.
The provider’s tool schema defines the arguments, and the model supplies their values.
Request configuration
Set request-level loop limits underbaseten.tool_settings:
On
Responses, the native max_tool_calls field sets a whole-request budget of server-side tool calls. When the loop spends the budget, Baseten steers the model to answer from the results it already has. Messages and ChatCompletions have no equivalent field.
tool_choice
tool_choice
Most requests can omit
tool_choice and let the model decide whether to use a tool. Set it when the first model iteration must call a tool, call a particular tool, or avoid tools.tool_choice applies only to the first model iteration. Later iterations use automatic selection so the model can stop calling tools and answer.If a request includes both server-side and application-side tool execution, the
require any tool forms allow the model to choose either type. Name the server-side tool when the first iteration must search.Response shapes
Each protocol returns the final answer through its normal response field and represents completed server-side calls differently. A turn that ends on an open application call reports the protocol’s tool-calling stop condition.Messages reports stop_reason: "tool_use", Responses has no stop field and carries the open call as a function_call item in output, and ChatCompletions reports finish_reason: "tool_calls".
Messages uses generic tool_use and tool_result blocks for tools that Baseten executes server-side. These blocks round-trip through Baseten’s Messages endpoint, but Anthropic’s API does not accept tool_result inside an assistant message. The top-level usage is the billed total across all model iterations, and usage.input_tokens excludes cache reads.
ChatCompletions concatenates the text of every iteration into choices[0].message.content. A preamble such as “I will search now” arrives attached to the answer with no separator. Read baseten.iterations[].continuation_messages for the separated transcript.
Responses uses completed mcp_call items for tools that Baseten executes server-side. server_label identifies the provider. Application tools remain standard function_call items.
baseten response metadata
The optional baseten object describes work across model iterations. Read it to display ChatCompletions tool execution progress, retain ChatCompletions search history, inspect per-iteration usage, or distinguish an iteration limit from a model token limit. A client that only displays the final answer can ignore it.
The object has two scopes. iterations[] holds one entry per internal model call. request holds fields that describe the whole HTTP request.
Extension example (ChatCompletions, buffered)
The billing fields
billable, sku, and quantity are provisional during early access. Their names and semantics can change without notice. sku can be null, and the meaning of quantity varies by provider.
Baseten may add fields to this object. Ignore fields that your client does not use.
Streaming metadata
Server-side tool execution supports buffered and streaming requests. Thebaseten object appears in these locations:
Streaming iteration entries are partial. Merge iterations by
index and ChatCompletions server-side calls by id. Append each continuation_messages array once, in arrival order.
ChatCompletions metadata chunks have choices: []. Check for an empty array before reading choices[0] in a hand-written streaming client.
Iteration limit
If the model continues to call server-side tools at the iteration limit, Baseten returns a resumable response withmax_react_iterations_reached:
The transcript ends with a completed server-side call and result. Send it back without a new user message to resume from that point, or retry the original request with a larger
max_react_iterations value.
In ChatCompletions, finish_reason: "length" without baseten.request.termination_reason means the model reached max_tokens. OpenAI SDK helpers can raise LengthFinishReasonError in either case. The completion remains available as error.completion.
Observability
- On enabled workspaces, a Model API page’s Metrics tab graphs server-side tool calls: throughput, throughput per tool, errors by error code, and call latency.
- Billed tool calls appear in workspace settings under Billing → Usage, in the Tool calls view, grouped by provider.
- Per-request detail is in the
basetenresponse metadata: per-iteration usage, call outcomes, andrequest.termination_reason. - The metrics export endpoint does not include server-side tool series. The usage and costs REST APIs report token counts only, with no tool-call dimension.
- A failure after a streaming response starts arrives as an SSE
errorevent, because the HTTP status is already200. Streaming clients must handle that event.
Limits and errors
Server-side tool execution implements a subset of each protocol. A request that uses a refused feature returns
400 instead of silently degrading.
Two output deviations from the stock protocols:
Messagesrepresents server-side calls as generictool_useandtool_resultblocks, not Anthropic’sserver_tool_useandweb_search_tool_resulttypes. Thinking blocks carrysignature: "erased". Echo these blocks back to Baseten only, not to Anthropic’s API.Responsesdoes not echo request parameters on the response envelope. Fields such astemperature,tools, andstorearenullon the response.
2xx response.
For general inference error guidance, see Inference errors.
Use a client read timeout longer than 285 seconds for buffered requests. Streaming responses send a : keep-alive comment line every 15 seconds while a server-side call runs.