All posts
·3 min

Integrated tools in the Sabiá API

The tools the Sabiá already uses in the chat (web search, code execution and Data Ocean) are now available in the API. You activate the ones you need on each request.

In the Sabiá chat, the model already searches the web, runs code and queries Brazil’s official data while it answers. Now those same tools are available in the API: you activate them on your own request and they run inside Maritaca’s infrastructure, without you having to build or maintain any of them.

The difference from function calling matters. With function calling, the model hands the work back to your code to run. With integrated tools, the work happens inside Maritaca: the model decides which tools to use, calls them in several steps and returns only the final answer. In the chat, this already happened behind the scenes. In the API, you choose which tools to turn on and get the result ready to use in your application.

The three tools

There are three tools, activated independently. Each one covers a different kind of need.

ToolAPI flagModelsWhat it does
Web searchweb_searchAll Sabiá modelsSearches the web and reads page content to answer with up-to-date information and the proper source.
Code executioncode_executionOnly sabia-4-thinkingRuns Python and Bash in a sandbox to compute, analyze data and generate files, such as charts and documents.
Data Oceandata_oceanOnly sabia-4-thinkingQueries dozens of official Brazilian databases, from population and companies to health, climate, public safety and the economy, always with real numbers and sources.

Availability varies by tool: web search works on all Sabiá models, while code execution and Data Ocean are available only on sabia-4-thinking. They all come turned off by default and are activated per request.

How it works

The flow is agentic and runs entirely on the server. You don’t need to orchestrate anything: the model handles the intermediate calls and returns just the result. There are three steps:

  1. Your request: you call the API and turn on the tools you want, or several at once.
  2. The work on the server: the Sabiá decides which tools to use and runs them in several steps, internally. The reasoning and the intermediate calls stay internal.
  3. The response: the API returns only the final answer, already with the sources cited and any files that were generated.

How to activate

You turn on the flags in the call itself, always with stream: false. With the OpenAI library, they go in extra_body. In the example below, the question combines the two: Data Ocean for the official data and web search for what is most recent.

from openai import OpenAI
 
client = OpenAI(
    api_key=“your-key”,
    base_url=https://chat.maritaca.ai/api,
)
 
response = client.chat.completions.create(
    model=“sabia-4-thinking”,
    stream=False,
    messages=[
        {“role”: “user”,
         “content”: “Is it worth opening a coffee shop in Cambuí, Campinas?”},
    ],
    extra_body={“web_search”: True, “data_ocean”: True},
)
 
print(response.choices[0].message.content)

You can combine as many tools as you want (just add code_execution for the third) and even use them alongside your own functions. Each response also reports how many executions occurred, in the usage.tool_execution_details field. The documentation has the full examples, the Responses API and the return formats, at docs.maritaca.ai.

Turning on data_ocean already enables web search and code execution automatically, since Data Ocean answers tend to cross official data with search and calculation.

What you can ask

A few examples of requests that each tool handles on its own, without you needing to fetch the data first or run anything on your side:

Web search

“What’s the current dollar exchange rate and what explains today’s move? Cite the sources.”

Code execution

“Analyze this sales spreadsheet and generate a chart with the month-by-month trend.”

Data Ocean

“Compare the average income and the number of companies in the three largest cities in the interior of São Paulo.”

Pricing

Executions are billed per use, on top of the normal token cost. The actual amounts consumed come in usage.tool_execution_details in every response. Since data_ocean turns on web search and code execution together, a request with data_ocean can be billed for all three tools: Data Ocean, web search and code execution.

ToolUnitPrice
Web searchper searchR$ 0.0165
Page readper page readR$ 0.066
Data Oceanper GB processedR$ 0.10
Code executionper minuteR$ 0.016

Availability

The integrated tools are already available via the API. Web search works on all Sabiá models; code execution and Data Ocean are available only on sabia-4-thinking. The documentation has the complete examples, the Responses API and the return formats, at docs.maritaca.ai.