Skip to main content

Module openai

Module openai 

Source
Expand description

OpenAI-compatible chat-completions adapter.

Targets the /chat/completions shape that OpenAI, Azure (via gateway), GLM (Zhipu), DeepSeek, Moonshot, Together, Ollama and many others speak. The only thing that varies is the base URL + model name + API key, which is all driven by config.

§Deferred tool loading (software-layer ToolSearch)

This provider implements the same deferred-tool pattern as AnthropicProvider but in pure software — no API-level defer_loading or tool_reference needed. On each complete_with_search / stream_with_search call:

  1. Only eager tools + ToolSearchTool are sent in the initial request.
  2. If the model calls ToolSearchTool, the query is resolved against the deferred list, the matched schemas are returned as plain JSON in a tool_result message, and a new request is sent with the matched tools appended to the eager list.
  3. Capped at max_search_rounds to prevent infinite loops.

Structs§

OpenAiProvider