Skip to content

Models

Use provider:model:

Provider Example
anthropic anthropic:claude-haiku-4-5 (prompt caching on)
openai openai:gpt-4o-mini
ollama ollama:qwen3.6:latest (local; the model must support tool calling)
lmstudio lmstudio:<model>
groq, deepseek, gemini, openrouter, together groq:llama-3.3-70b-versatile

Google models use the name gemini (Gemini's OpenAI-compatible endpoint, key in GEMINI_API_KEY), not google. Models from OpenRouter use their OpenRouter ID after the provider name, so a Gemini model through OpenRouter is openrouter:google/<model-name> with OPENROUTER_API_KEY. The model must support tool calling.

Your own provider (Azure OpenAI, AWS Bedrock, an internal gateway) works too; see Bring your own model.

A service that speaks the Anthropic or OpenAI API

If you run a gateway, proxy or wrapper that exposes the Anthropic Messages API (/v1/messages) or an OpenAI-style API, you do not need any code. Point the built-in provider at it:

export ANTHROPIC_BASE_URL=http://localhost:3000    # where the service listens
export ANTHROPIC_API_KEY=any-value                 # the SDK needs one; use the real key if the service checks it
selfbrowse --model anthropic:haiku "task"          # the model name is whatever the service accepts
from selfbrowse.llm import make_llm
BrowseAgent("task", llm=make_llm("anthropic:haiku", base_url="http://localhost:3000", api_key="any-value"))

For an OpenAI-style service, set OPENAI_BASE_URL and OPENAI_API_KEY and use openai:<model>.

  • The service must support tool calling on that endpoint: a tools list in the request and tool_use blocks (or OpenAI tool_calls) in the reply. A service that only takes a text prompt needs a custom model instead; see Bring your own model.
  • Wrappers around another agent add weight. A service that runs a coding agent behind the endpoint may add its own system prompt and tools to every call. That inflates token counts, so compare cost, not tokens, across setups. Check that the wrapper does not give the model tools of its own, such as a shell.
  • Test with a small task first, for example selfbrowse --model anthropic:haiku "Open example.com and tell me the page heading".

Bring your own model

Any provider works if you give Selfbrowse an object with a model name and a complete(system=, messages=, tools=, max_tokens=) method that returns an LLMResponse. Messages and tools arrive as Anthropic-style blocks, so you translate to and from your SDK.

If your SDK speaks the OpenAI chat format (Azure OpenAI, and other OpenAI-compatible services), reuse the built-in translation:

# my_llm.py
from openai import AzureOpenAI
from selfbrowse.llm.openai_compat import messages_to_openai, tools_to_openai, response_from_openai

class AzureLLM:
    model = "my-gpt4o-deployment"            # shown in traces

    def __init__(self):
        self.client = AzureOpenAI(azure_endpoint="https://RESOURCE.openai.azure.com",
                                  api_key="...", api_version="2024-10-21")

    def complete(self, *, system, messages, tools, max_tokens=2048):
        resp = self.client.chat.completions.create(
            model=self.model, max_tokens=max_tokens,
            messages=messages_to_openai(system, messages),
            tools=tools_to_openai(tools),
        )
        return response_from_openai(resp)

Use it from Python, the command line or the MCP server:

BrowseAgent("task", llm=AzureLLM()).run()          # an object
BrowseAgent("task", llm="my_llm:AzureLLM").run()   # the same, by name
selfbrowse --model my_llm:AzureLLM "task"          # a module on your path, or in the folder you run from
selfbrowse --model ./my_llm.py:AzureLLM "task"     # or a file
selfbrowse-mcp --model ./my_llm.py:AzureLLM

The name after the colon can be a class (created with no arguments), a function that returns a model, or a ready object. Any provider: that is not built in is looked up this way, so a mistyped provider says so instead of failing quietly.

For a service with its own format (AWS Bedrock's Converse API, Vertex, an internal gateway), build the LLMResponse yourself: content is a list of {"type": "text", "text": ...} and {"type": "tool_use", "id", "name", "input"} blocks, stop_reason is "tool_use" or "end_turn", and usage is a selfbrowse.types.Usage with your token counts so traces and budgets work. selfbrowse/llm/base.py has the full interface.

These routes are tested with a fake model. They have not been run against live Azure or AWS accounts.