KosmoKrator

data

Brave Search Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Brave Search KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.brave_search.*. Use lua_read_doc("integrations.brave-search") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Brave Search workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.brave_search.web({}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("brave-search"))' --json
kosmo integrations:lua --eval 'print(docs.read("brave-search.web"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local brave_search = app.integrations.brave_search
local result = brave_search.web({})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.brave_search, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.brave_search.default.* or app.integrations.brave_search.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Brave Search, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Brave Search

Namespace: brave-search

Use this integration for Brave’s independent search APIs: web, LLM Context, images, news, videos, places, local details, autosuggest, spellcheck, rich callbacks, AI Answers, and legacy Summarizer retrieval.

Authentication

Configure api_key. The integration sends it as the X-Subscription-Token header required by Brave Search.

Tools

  • brave_search_web: web search. Use summary=true to request a legacy summarizer key, or enable_rich_callback=true to request a rich callback key.
  • brave_search_web_rich: fetch rich results using a callback_key.
  • brave_search_llm_context: GET /llm/context for LLM-ready grounding data.
  • brave_search_llm_context_post: POST /llm/context for larger payloads.
  • brave_search_images, brave_search_news, brave_search_videos: media and news search endpoints.
  • brave_search_places: geographic place and POI search.
  • brave_search_local_pois, brave_search_local_descriptions: fetch details for ephemeral POI IDs returned by web or place search.
  • brave_search_suggest, brave_search_spellcheck: query assistance.
  • brave_search_answer: OpenAI-compatible Brave Answers chat completions.
  • brave_search_summarizer*: legacy Summarizer endpoints. Brave documents Summarizer as deprecated in favor of Answers; use only for existing flows.

Return Notes

Responses keep Brave’s upstream JSON shape. The integration does not rename fields such as web.results, grounding, sources, results, query, summarizer, summary, or OpenAI-compatible choices.

For local-aware web or LLM Context queries, pass location header values as loc_lat, loc_long, loc_city, loc_state, loc_state_name, loc_country, or loc_postal_code. POI IDs are ephemeral and expire after about eight hours; do not store them as durable identifiers.

Examples

local web = tools.brave_search_web({
  q = "site:github.com laravel queue monitoring",
  count = 10,
  freshness = "pm",
  extra_snippets = true
})

local context = tools.brave_search_llm_context({
  q = "current OpenTelemetry PHP instrumentation best practices",
  maximum_number_of_tokens = 4096,
  context_threshold_mode = "balanced"
})

local places = tools.brave_search_places({
  latitude = 37.7749,
  longitude = -122.4194,
  q = "coffee shops",
  radius = 1000,
  count = 5
})

local answer = tools.brave_search_answer({
  stream = false,
  messages = {
    { role = "user", content = "What changed in Brave Search API this year?" }
  }
})
Raw agent markdown
# Brave Search

Namespace: `brave-search`

Use this integration for Brave's independent search APIs: web, LLM Context,
images, news, videos, places, local details, autosuggest, spellcheck, rich
callbacks, AI Answers, and legacy Summarizer retrieval.

## Authentication

Configure `api_key`. The integration sends it as the
`X-Subscription-Token` header required by Brave Search.

## Tools

- `brave_search_web`: web search. Use `summary=true` to request a legacy
  summarizer key, or `enable_rich_callback=true` to request a rich callback key.
- `brave_search_web_rich`: fetch rich results using a `callback_key`.
- `brave_search_llm_context`: GET `/llm/context` for LLM-ready grounding data.
- `brave_search_llm_context_post`: POST `/llm/context` for larger payloads.
- `brave_search_images`, `brave_search_news`, `brave_search_videos`: media and
  news search endpoints.
- `brave_search_places`: geographic place and POI search.
- `brave_search_local_pois`, `brave_search_local_descriptions`: fetch details
  for ephemeral POI IDs returned by web or place search.
- `brave_search_suggest`, `brave_search_spellcheck`: query assistance.
- `brave_search_answer`: OpenAI-compatible Brave Answers chat completions.
- `brave_search_summarizer*`: legacy Summarizer endpoints. Brave documents
  Summarizer as deprecated in favor of Answers; use only for existing flows.

## Return Notes

Responses keep Brave's upstream JSON shape. The integration does not rename
fields such as `web.results`, `grounding`, `sources`, `results`, `query`,
`summarizer`, `summary`, or OpenAI-compatible `choices`.

For local-aware web or LLM Context queries, pass location header values as
`loc_lat`, `loc_long`, `loc_city`, `loc_state`, `loc_state_name`,
`loc_country`, or `loc_postal_code`. POI IDs are ephemeral and expire after
about eight hours; do not store them as durable identifiers.

## Examples

```lua
local web = tools.brave_search_web({
  q = "site:github.com laravel queue monitoring",
  count = 10,
  freshness = "pm",
  extra_snippets = true
})

local context = tools.brave_search_llm_context({
  q = "current OpenTelemetry PHP instrumentation best practices",
  maximum_number_of_tokens = 4096,
  context_threshold_mode = "balanced"
})

local places = tools.brave_search_places({
  latitude = 37.7749,
  longitude = -122.4194,
  q = "coffee shops",
  radius = 1000,
  count = 5
})

local answer = tools.brave_search_answer({
  stream = false,
  messages = {
    { role = "user", content = "What changed in Brave Search API this year?" }
  }
})
```
Metadata-derived Lua example
local result = app.integrations.brave_search.web({})
print(result)

Functions

web Read

Search Brave web results.

Lua path
app.integrations.brave_search.web
Full name
brave-search.brave_search_web
ParameterTypeRequiredDescription
No parameters.
web_rich_callback Read

Fetch rich result details from a web search callback key.

Lua path
app.integrations.brave_search.web_rich_callback
Full name
brave-search.brave_search_web_rich
ParameterTypeRequiredDescription
No parameters.
llm_context Read

Retrieve LLM-ready extracted web context with GET.

Lua path
app.integrations.brave_search.llm_context
Full name
brave-search.brave_search_llm_context
ParameterTypeRequiredDescription
No parameters.
llm_context_post Read

Retrieve LLM-ready extracted web context with POST.

Lua path
app.integrations.brave_search.llm_context_post
Full name
brave-search.brave_search_llm_context_post
ParameterTypeRequiredDescription
No parameters.
image Read

Search Brave image results.

Lua path
app.integrations.brave_search.image
Full name
brave-search.brave_search_images
ParameterTypeRequiredDescription
No parameters.
news Read

Search Brave news results.

Lua path
app.integrations.brave_search.news
Full name
brave-search.brave_search_news
ParameterTypeRequiredDescription
No parameters.
video Read

Search Brave video results.

Lua path
app.integrations.brave_search.video
Full name
brave-search.brave_search_videos
ParameterTypeRequiredDescription
No parameters.
place Read

Search Brave places and points of interest.

Lua path
app.integrations.brave_search.place
Full name
brave-search.brave_search_places
ParameterTypeRequiredDescription
No parameters.
local_pois Read

Fetch details for ephemeral Brave local place IDs.

Lua path
app.integrations.brave_search.local_pois
Full name
brave-search.brave_search_local_pois
ParameterTypeRequiredDescription
No parameters.
local_descriptions Read

Fetch AI-generated descriptions for ephemeral Brave local place IDs.

Lua path
app.integrations.brave_search.local_descriptions
Full name
brave-search.brave_search_local_descriptions
ParameterTypeRequiredDescription
No parameters.
autosuggest Read

Get Brave query suggestions.

Lua path
app.integrations.brave_search.autosuggest
Full name
brave-search.brave_search_suggest
ParameterTypeRequiredDescription
No parameters.
spellcheck Read

Get Brave spelling corrections for a query.

Lua path
app.integrations.brave_search.spellcheck
Full name
brave-search.brave_search_spellcheck
ParameterTypeRequiredDescription
No parameters.
answer Read

Create a Brave grounded answer through the OpenAI-compatible endpoint.

Lua path
app.integrations.brave_search.answer
Full name
brave-search.brave_search_answer
ParameterTypeRequiredDescription
No parameters.
summarizer Read

Fetch a legacy summarizer search result by key.

Lua path
app.integrations.brave_search.summarizer
Full name
brave-search.brave_search_summarizer
ParameterTypeRequiredDescription
No parameters.
summarizer_summary Read

Fetch just the legacy summarizer summary by key.

Lua path
app.integrations.brave_search.summarizer_summary
Full name
brave-search.brave_search_summarizer_summary
ParameterTypeRequiredDescription
No parameters.
summarizer_title Read

Fetch just the legacy summarizer title by key.

Lua path
app.integrations.brave_search.summarizer_title
Full name
brave-search.brave_search_summarizer_title
ParameterTypeRequiredDescription
No parameters.
summarizer_enrichments Read

Fetch legacy summarizer enrichments by key.

Lua path
app.integrations.brave_search.summarizer_enrichments
Full name
brave-search.brave_search_summarizer_enrichments
ParameterTypeRequiredDescription
No parameters.
summarizer_followups Read

Fetch legacy summarizer follow-up questions by key.

Lua path
app.integrations.brave_search.summarizer_followups
Full name
brave-search.brave_search_summarizer_followups
ParameterTypeRequiredDescription
No parameters.
summarizer_entity_info Read

Fetch legacy summarizer entity information by key.

Lua path
app.integrations.brave_search.summarizer_entity_info
Full name
brave-search.brave_search_summarizer_entity_info
ParameterTypeRequiredDescription
No parameters.