Skip to content

teff.provider.builtin

teff.provider.builtin

Built-in provider presets — subclasses of :class:Provider.

Modules:

Name Description
anthropic

Anthropic preset (responses normalised to a shared message shape).

base

The :class:Provider value object.

deepseek

DeepSeek preset.

gemini

Gemini preset (Google's OpenAI-compatible endpoint).

groq

Groq preset.

mistral

Mistral preset.

ollama

Ollama preset (local).

openai

AI provider presets (subclasses of :class:Provider).

openai_compatible

Generic OpenAI-compatible provider (vLLM, LM Studio, Azure, ...).

openrouter

OpenRouter preset.

together

Together preset.

Classes:

Name Description
Anthropic

Anthropic /messages endpoint.

DeepSeek

DeepSeek's OpenAI-compatible endpoint.

Gemini

Google's openai protocol endpoint.

Groq

Groq's OpenAI-compatible endpoint.

Mistral

Mistral's OpenAI-compatible endpoint.

Ollama

Ollama's local /api/chat endpoint.

OpenAI

OpenAI chat-completions endpoint.

OpenAICompatible

Any /chat/completions endpoint; set base_url yourself.

OpenRouter

OpenRouter's OpenAI-compatible endpoint.

Provider

A named model endpoint: wire protocol + endpoint data.

Together

Together.ai's OpenAI-compatible endpoint.

Anthropic

Bases: Provider

Anthropic /messages endpoint.

Source code in teff/provider/builtin/anthropic.py
 6
 7
 8
 9
10
11
12
13
14
15
class Anthropic(Provider):
    """Anthropic ``/messages`` endpoint."""

    name = "anthropic"
    type = "anthropic_compatible"
    base_url = "https://api.anthropic.com/v1"
    chat_path = "/messages"
    api_key_env = "ANTHROPIC_API_KEY"
    auth_header = "x-api-key"
    auth_prefix = ""

DeepSeek

Bases: Provider

DeepSeek's OpenAI-compatible endpoint.

Source code in teff/provider/builtin/deepseek.py
 6
 7
 8
 9
10
11
class DeepSeek(Provider):
    """DeepSeek's OpenAI-compatible endpoint."""

    name = "deepseek"
    base_url = "https://api.deepseek.com/v1"
    api_key_env = "DEEPSEEK_API_KEY"

Gemini

Bases: Provider

Google's openai protocol endpoint.

Source code in teff/provider/builtin/gemini.py
 6
 7
 8
 9
10
11
class Gemini(Provider):
    """Google's ``openai`` protocol endpoint."""

    name = "gemini"
    base_url = "https://generativelanguage.googleapis.com/v1beta/openai"
    api_key_env = "GEMINI_API_KEY"

Groq

Bases: Provider

Groq's OpenAI-compatible endpoint.

Source code in teff/provider/builtin/groq.py
 6
 7
 8
 9
10
11
class Groq(Provider):
    """Groq's OpenAI-compatible endpoint."""

    name = "groq"
    base_url = "https://api.groq.com/openai/v1"
    api_key_env = "GROQ_API_KEY"

Mistral

Bases: Provider

Mistral's OpenAI-compatible endpoint.

Source code in teff/provider/builtin/mistral.py
 6
 7
 8
 9
10
11
class Mistral(Provider):
    """Mistral's OpenAI-compatible endpoint."""

    name = "mistral"
    base_url = "https://api.mistral.ai/v1"
    api_key_env = "MISTRAL_API_KEY"

Ollama

Bases: Provider

Ollama's local /api/chat endpoint.

Source code in teff/provider/builtin/ollama.py
 6
 7
 8
 9
10
11
12
13
14
15
class Ollama(Provider):
    """Ollama's local ``/api/chat`` endpoint."""

    name = "ollama"
    type = "ollama"
    base_url = "http://localhost:11434"
    chat_path = "/api/chat"
    api_key_env = ""
    auth_header = ""
    auth_prefix = ""

OpenAI

Bases: Provider

OpenAI chat-completions endpoint.

Source code in teff/provider/builtin/openai.py
 6
 7
 8
 9
10
11
class OpenAI(Provider):
    """OpenAI chat-completions endpoint."""

    name = "openai"
    base_url = "https://api.openai.com/v1"
    api_key_env = "OPENAI_API_KEY"

OpenAICompatible

Bases: Provider

Any /chat/completions endpoint; set base_url yourself.

Source code in teff/provider/builtin/openai_compatible.py
 6
 7
 8
 9
10
11
class OpenAICompatible(Provider):
    """Any ``/chat/completions`` endpoint; set ``base_url`` yourself."""

    name = "openai_compatible"
    base_url = ""
    api_key_env = "OPENAI_API_KEY"

OpenRouter

Bases: Provider

OpenRouter's OpenAI-compatible endpoint.

Source code in teff/provider/builtin/openrouter.py
 6
 7
 8
 9
10
11
class OpenRouter(Provider):
    """OpenRouter's OpenAI-compatible endpoint."""

    name = "openrouter"
    base_url = "https://openrouter.ai/api/v1"
    api_key_env = "OPENROUTER_API_KEY"

Provider

A named model endpoint: wire protocol + endpoint data.

name is the registry key used by provider= references. type is the protocol discriminator — openai_compatible / anthropic_compatible / ollama — and decides the request body, streaming chunk parsing, and response extraction held by :class:~teff.harness.Harness.

Built-in presets subclass this and set name (and the other fields) once; a custom provider is a plain instance. Fields may be overridden at construction:

Provider(name="my-vllm", type="openai_compatible", base_url="http://vllm:8000/v1")

type is deliberately a distinct concept from name: the name is just a key and never carries protocol meaning.

Methods:

Name Description
from_mapping

Build from a config dict, keeping only known fields.

to_dict

All provider fields as a plain dict (for YAML serialisation).

Source code in teff/provider/builtin/base.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Provider:
    """A named model endpoint: wire protocol + endpoint data.

    ``name`` is the registry key used by ``provider=`` references.
    ``type`` is the protocol discriminator — ``openai_compatible`` /
    ``anthropic_compatible`` / ``ollama`` — and decides the request body,
    streaming chunk parsing, and response extraction held by
    :class:`~teff.harness.Harness`.

    Built-in presets subclass this and set ``name`` (and the other fields)
    once; a custom provider is a plain instance.  Fields may be overridden
    at construction:

        Provider(name="my-vllm", type="openai_compatible", base_url="http://vllm:8000/v1")

    ``type`` is deliberately a distinct concept from ``name``: the name is
    just a key and never carries protocol meaning.
    """

    name: str = ""
    type: str = "openai_compatible"
    base_url: str = ""
    chat_path: str = "/chat/completions"
    api_key_env: str = ""
    auth_header: str = "Authorization"
    auth_prefix: str = "Bearer "
    timeout: float = 120.0

    def __init__(self, **overrides):
        unknown = set(overrides) - set(PROVIDER_FIELDS)
        if unknown:
            raise TypeError(f"unknown Provider field(s): {', '.join(sorted(unknown))}")
        for field in PROVIDER_FIELDS:
            if field in overrides:
                setattr(self, field, overrides[field])

    @classmethod
    def from_mapping(cls, cfg: dict) -> "Provider":
        """Build from a config dict, keeping only known fields."""
        return cls(**{f: cfg[f] for f in PROVIDER_FIELDS if f in cfg})

    def to_dict(self) -> dict:
        """All provider fields as a plain dict (for YAML serialisation)."""
        return {f: getattr(self, f) for f in PROVIDER_FIELDS}

    def __repr__(self) -> str:
        shown = ", ".join(
            f"{f}={getattr(self, f)!r}" for f in PROVIDER_FIELDS if getattr(self, f)
        )
        return f"{type(self).__name__}({shown})"

from_mapping classmethod

from_mapping(cfg)

Build from a config dict, keeping only known fields.

Source code in teff/provider/builtin/base.py
58
59
60
61
@classmethod
def from_mapping(cls, cfg: dict) -> "Provider":
    """Build from a config dict, keeping only known fields."""
    return cls(**{f: cfg[f] for f in PROVIDER_FIELDS if f in cfg})

to_dict

to_dict()

All provider fields as a plain dict (for YAML serialisation).

Source code in teff/provider/builtin/base.py
63
64
65
def to_dict(self) -> dict:
    """All provider fields as a plain dict (for YAML serialisation)."""
    return {f: getattr(self, f) for f in PROVIDER_FIELDS}

Together

Bases: Provider

Together.ai's OpenAI-compatible endpoint.

Source code in teff/provider/builtin/together.py
 6
 7
 8
 9
10
11
class Together(Provider):
    """Together.ai's OpenAI-compatible endpoint."""

    name = "together"
    base_url = "https://api.together.xyz/v1"
    api_key_env = "TOGETHER_API_KEY"