Add native web search with per-search billing#83
Merged
Conversation
Add an opt-in `web_search` flag to chat and text completion requests that enables each provider's built-in web search and bills per search on top of token usage. - model_registry: per-search USD pricing (provider list prices) via get_web_search_price_usd + provider_supports_web_search predicate - llm_backend: get_chat_model_cached gains a web_search arg (OpenAI uses the Responses API, xAI sets search_parameters); get_web_search_tool returns the bind-time tool spec for OpenAI/Anthropic/Google; extract_web_search_count counts the billable unit per provider (calls/requests/sources/grounded req) - controllers: parse and forward the flag, bind the web search tool alongside user tools, cover the flag in the signed request hash, and pass the detected search count into compute_session_cost (streaming + non-streaming) - pricing: compute_session_cost adds the per-search surcharge - models + openapi: add the web_search request field - tests: provider pricing, tool specs, count extraction, surcharge math, and controller binding/billing integration Providers without native web search (ByteDance/ModelArk) ignore the flag and are not charged.
…-models-WUZcG # Conflicts: # tee_gateway/controllers/chat_controller.py # tee_gateway/model_registry.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an opt-in
web_searchflag to chat and text completion requests thatenables each provider's built-in web search and bills per search on top of
token usage.
get_web_search_price_usd + provider_supports_web_search predicate
Responses API, xAI sets search_parameters); get_web_search_tool returns the
bind-time tool spec for OpenAI/Anthropic/Google; extract_web_search_count
counts the billable unit per provider (calls/requests/sources/grounded req)
user tools, cover the flag in the signed request hash, and pass the detected
search count into compute_session_cost (streaming + non-streaming)
controller binding/billing integration
Providers without native web search (ByteDance/ModelArk) ignore the flag and
are not charged.