curated_feed.openai_compat

The scorer for any endpoint that speaks OpenAI’s Chat Completions API.

OpenAI itself, OpenRouter, Ollama, vLLM, a confidential-computing proxy: the same class, pointed at a different base_url. That is why it is written to what these servers have in common rather than to OpenAI’s own API, and four choices follow from it.

Chat Completions, not Responses. It is the API the other servers copy.

Plain string message content. The policy documents are the system message and come first, so a server that caches prompt prefixes can reuse them; nothing is marked for caching, because there is no portable way to ask.

The stream is read chunk by chunk rather than through the SDK’s stream helper, which assumes OpenAI’s exact chunk shape. Reasoning that a server returns in a field of its own (reasoning_content) is ignored; reasoning it returns inline is stripped by score.parse_response.

`max_completion_tokens`, not `max_tokens`. OpenAI’s reasoning models refuse the older name; a server that predates the newer one may ignore it, in which case its own default ceiling applies and truncation is still caught by the finish reason.

Attributes

Classes

OpenAICompatibleScorer

Scores a day of candidates through an OpenAI-compatible endpoint.

Functions

build_client(→ openai.OpenAI)

A client for base_url, or for OpenAI when it is empty.

Module Contents

curated_feed.openai_compat.TRUNCATED = 'length'
curated_feed.openai_compat.FILTERED = 'content_filter'
class curated_feed.openai_compat.OpenAICompatibleScorer(*, model: str, max_tokens: int, effort: str = '', base_url: str = '', timeout_seconds: float | None = None, client: openai.OpenAI | None = None)[source]

Scores a day of candidates through an OpenAI-compatible endpoint.

name = 'openai'
model
max_tokens
effort = ''
usage
generate(candidates: collections.abc.Sequence[curated_feed.models.Candidate], prompt: curated_feed.policy.Prompt, *, feedback: str | None = None) → str[source]

One call: the day’s prompt in, the raw response text out.

curated_feed.openai_compat.build_client(*, base_url: str, timeout_seconds: float | None) → openai.OpenAI[source]

A client for base_url, or for OpenAI when it is empty.

The key is the SDK’s to find, in OPENAI_API_KEY. Unlike the Anthropic SDK it refuses to build a client without one, so a missing key is reported here rather than on the first call. A local server that needs no key still needs the variable set, to anything.

Public because it is the seam a test substitutes, as claude.build_client.