Every LLM client in Gwenflow subclasses ChatBase and exposes the same four methods, takes the same messages and returns the same ModelResponse. Changing provider is changing one line.

Providers

Anthropic, Google and Mistral use their native SDKs; the others speak the OpenAI Chat Completions format. Every client accepts api_key= to pass the key directly, and timeout and retry settings for its SDK.

OpenAI and compatible servers

ChatOpenAI takes the usual sampling parameters (temperature, top_p, max_completion_tokens, seed, stop, presence_penalty, frequency_penalty, logprobs…), reasoning_effort for reasoning models and prompt_cache_key. With base_url it talks to any OpenAI-compatible server: vLLM, LM Studio, Scaleway, a gateway.

Anthropic

thinking turns on extended thinking; see Reasoning.

Google

Azure OpenAI

azure_endpoint, azure_deployment and api_version fall back on AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT and AZURE_OPENAI_API_VERSION.

Ollama and local models

ChatOllama extracts the <think>...</think> blocks local reasoning models write inline into separate thinking parts.

Gwenlake

ChatGwenlake calls the models served by Gwenlake, at https://integrate.api.gwenlake.com/v1 by default. It reads GWENLAKE_API_KEY, and GWENLAKE_ORGANIZATION when set.

Calling a model

Call await llm.aclose() to release the async HTTP client when you are done with it.

Structured answers

Set response_format to a Pydantic model and response.parsed holds the validated object:
On an agent, use response_model instead: it also works while tools are on offer. See Structured output.

Context window

The agent keeps its history within the model’s context window, so it needs to know it. llm.context_window_info() tells the size and where it comes from, resolved in this order:
  1. context_window=<int>: an explicit value, for instance a vLLM server started with a smaller --max-model-len;
  2. context_window="auto": read from the server’s /models listing (max_model_len, context_length or context_window) on OpenAI-compatible clients;
  3. the built-in table of known models (gwenflow.llms.models.MODELS), matched without case and without a provider or organisation prefix, so Qwen/Qwen3.6-27B-AWQ finds qwen3.6-27b;
  4. fallback_context_window=<int>: a value used only for a model found nowhere else;
  5. 128,000 tokens, with a warning logged once.
The agent lets its history use 75 % of the window and leaves the rest for the answer. See Context management.

Addressing models by name

Flows and the command line name a model as provider/model-name. make_llm builds the client from that string, with any extra keyword argument passed through:
The provider keys are openai, anthropic, google (or gemini), mistral, azure, deepseek, ollama and gwenlake.