Skip to content

Wire base_url + protocol through to protocol clients #230

@Kamilbenkirane

Description

@Kamilbenkirane

Problem

Users cannot point celeste at OpenAI-compatible or Anthropic-compatible APIs (MiniMax, vLLM, Ollama, LocalAI, etc.). The base_url parameter exists in method signatures (generate(), analyze(), stream.generate()) but never reaches _build_url() — it's dead plumbing.

Surfaced by #200.

Root Cause

_build_url() in both protocol clients (OpenResponsesClient, ChatCompletionsClient) reads from self._default_base_url (a ClassVar). The base_url parameter flows through namespace/modality layers but:

  1. _predict() doesn't have an explicit base_url param — it falls into **parameters
  2. Protocol _make_request() / _make_stream_request() don't have base_url as a named param — it falls into **parameters and is ignored
  3. _build_url() never sees it

Proposed Solution

Add protocol= + base_url= to create_client() and domain namespace methods:

# Anthropic-compatible (chatcompletions protocol)
await celeste.text.generate(
    "Explain quantum computing",
    model="MiniMax-M2.5",
    protocol="chatcompletions",
    base_url="https://api.minimax.io/anthropic",
    api_key="your-key",
)

# OpenAI-compatible (openresponses protocol)
await celeste.text.generate(
    "Hello",
    model="lfm2:latest",
    protocol="openresponses",
    base_url="http://localhost:11434",
)

Implementation

  1. Add base_url to create_client() — store as instance attribute on the client
  2. _build_url() uses self._base_url or self._default_base_url
  3. Add protocol= as a way to select wire format without implying a provider identity
  4. Relax model resolution when base_url is present — model + protocol + base_url should not hard-fail on unregistered models
  5. Remove base_url from per-call method signatures (belongs on the client, not per-call)
  6. Remove Ollama's custom base_url handling in OllamaGenerateClient._make_request() — use the generic mechanism

Protocol mapping

Protocol Providers using it
openresponses OpenAI, xAI, Ollama
chatcompletions Anthropic, DeepSeek, Groq, HuggingFace, Mistral, Moonshot, Cerebras
Custom Google (GenerateContent), Cohere

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions