Connecting to other LLMs
An adapter connects Search2o to an LLM. Six are bundled: three for every endpoint that speaks the OpenAI, Anthropic or Gemini protocol, and three for models you host with Ollama, vLLM or SGLang. An LLM with a protocol of its own needs an adapter class, written in Python and named on the Hooks page.
First, try a bundled adapter
A private deployment, a gateway, or a vendor with an OpenAI-compatible API does not need code: create an LLM profile under Profiles › LLM, choose the adapter that matches the protocol (openai, anthropic or gemini), and set the URL, the headers and the model. A model served by Ollama, vLLM or SGLang takes the ollama, vllm or sglang adapter. See LLM vendors.
The UI shows each adapter's description when a profile is created, and the description says which protocol the adapter speaks.
When you need an adapter of your own
An adapter turns the request Search2o builds, with the prompt, tools, model and limits, into the vendor's request body, and turns the vendor's response back into Search2o's form. Write one only when the vendor's protocol matches none of the bundled adapters.
BaseLlmAdapter, for most APIs
search2o.llm.basellmadapter.BaseLlmAdapter does the assembly and the control flow. It builds the request in a fixed order, merges the profile's additionalParams over the result, and reads the response in a fixed order. You supply the vendor-specific pieces, as these methods:
| Method | What it does |
|---|---|
namefrom LlmAdapter | The adapter's name, as it appears in a profile's adapter field. |
descriptionfrom LlmAdapter | One line, shown in the UI when a profile is created. |
set_model | Put the profile's model into the request parameters. |
set_max_tokens | Put the token ceiling into the request parameters. |
set_tools | Express the agent's tools in the vendor's schema. |
set_system_prompt | Place the system prompt where the vendor expects it, in the parameters or as a message. |
set_messages_user_entry | Append one user message. |
set_messages_assistant_response_content_output | Append an earlier assistant answer. |
set_messages_assistant_response_tool_calls | Append the assistant's earlier tool calls. |
set_messages_tool_results | Append the results of those tool calls. |
set_response_flags | Read success or failure from the response. |
set_token_counts | Read the token counts, which the cost report is computed from. |
set_assistant_vendor | Read the answer: either tool calls or content. A response with neither is an error. |
BaseLlmAdapter goes through the prompt history and calls the four message methods in the order the exchange happened, so an adapter never sorts the history itself. get_error has a working implementation that reads the response's error field; override it when the vendor reports errors differently.
LlmAdapter, for anything else
search2o.llm.llmadapter.LlmAdapter is the bare interface, for a protocol so different that the assembly above does not help. An adapter that extends it implements all five methods: name, description, process_request (an LlmRequestModel in, the request body out), process_response (the response in, an LlmResponseModel out), and get_error.
The bundled adapters in search2o.llm are the reference implementations, and each is a short file: openaiadapter.py, anthropicadapter.py and geminiadapter.py. ollamaadapter.py, vllmadapter.py and sglangadapter.py extend the OpenAI adapter.
Registering an adapter
- Install the class, with a constructor that takes no arguments, in the Python environment of every agent server.
- On the Hooks page, under LLM adapters, add a line
mypackage.myadapter.MyAdapterand save. - Restart the agent servers. Each builds the class once at startup and then offers the adapter under Adapters when a new LLM profile is created. A class that cannot be imported or built is written to the agent server's log, and that agent server refuses to run agents until the line is fixed.

