factor_agent.llm.openai_compatible.OpenAICompatibleBackend#

class OpenAICompatibleBackend(model, base_url, api_key_env=None, max_tokens=None, max_completion_tokens=None, reasoning_effort=None, timeout_seconds=600.0)[source]#

Bases: object

Complete a request with one chat-completions call.

Parameters:
modelstr

The model of every call.

base_urlstr

The provider’s endpoint, such as https://api.deepseek.com/v1.

api_key_envstr, optional

The environment variable holding the key; None for a local server without one.

max_tokensint, optional

The max_tokens of every call; the provider’s default if None.

max_completion_tokensint, optional

The max_completion_tokens of every call, in place of max_tokens: OpenAI’s reasoning models take only this one, and count the reasoning tokens in it.

reasoning_effortstr, optional

The reasoning_effort of every call (such as "low", "medium", "high"), for a reasoning model; the provider’s default if None.

timeout_secondsfloat

Seconds a call may take.

Raises:
ValueError

If both max_tokens and max_completion_tokens are given.

Methods#

OpenAICompatibleBackend.complete

Send request's prompt as one user message.

OpenAICompatibleBackend.from_config

Build from a role's config: model, base_url and optionally api_key_env, max_tokens or max_completion_tokens, reasoning_effort and timeout_seconds.

Attributes#

OpenAICompatibleBackend.OPTIONS = ('base_url', 'api_key_env', 'max_tokens', 'max_completion_tokens', 'reasoning_effort', 'timeout_seconds')#

The options a role’s config may give besides backend and model; base_url is needed.

OpenAICompatibleBackend.params#

The parameters every call sends with the prompt.