Skip to main content

Models Provider

Models Provider gives applications one interface for selecting models, resolving provider access, creating chat models, and collecting usage. Model metadata is loaded privately from the public models.dev catalogue.

Installation

pip install models-provider

Public flow

Pass provider values directly to Models, then select a provider-qualified model:

from models_provider import Models

models = Models({
    "openai": "OPENAI_API_KEY",
})

model = models.chat(
    "openai/gpt-4.1-mini",
    temperature=0.2,
    top_p=0.9,
)

answer = model.invoke("Explain spaced repetition in two sentences.")

Models() fetches the fixed models.dev catalogue once during initialization and caches it internally. Applications do not load or construct a catalogue.

The model identifier describes the model publisher, not the authentication mechanism. The access implementation is selected internally from the provider and the supplied values. For example, openai/gpt-5 remains the model identifier when the available access is an API key or an OpenAI account session.

Provider values

The constructor accepts one ordinary dictionary. Values can be literal credentials, environment-variable names, or provider-specific mappings:

Models({"openai": "sk-proj-...7Qx2"})
Models({"openai": "OPENAI_API_KEY"})

An uppercase environment-variable name is resolved from the process environment. Persistence is owned by the embedding application; Models Provider does not expose a credential-store abstraction or load credential files.

OAuth

OAuth values use the same dictionary. The host controls how the authorization URL is displayed:

models = Models()

authorization = await models.sign_in("openai")
# The host uses authorization.url to open the authorization page for the user.
await authorization.complete()

model = models.chat("openai/gpt-5", authorization=authorization)

The login flow and token refresh are provider-owned. Each authorization is independent, so the same Models instance can serve different users. The host decides whether and how to persist a user's authorization values.

Model contract

models.chat(
    "provider/model",
    temperature=0.2,
    top_p=0.9,
    reasoning_effort="high",
    max_output_tokens=512,
) -> BaseChatModel

Request settings are ordinary keyword arguments. The selected access implementation validates and translates them to its transport. There is no public options object and no provider-specific access class required from the caller.

Reuse the returned model across related calls. Account-backed transports keep private connection and cache affinity for that model's lifetime, while message history remains owned by the caller.

Usage values

Normalized usage is grouped by measurement type:

usage.tokens.input_tokens
usage.tokens.reasoning_tokens
usage.cache.cache_read_tokens
usage.audio.output_audio_tokens
usage.cost.cost_usd

UsageLedger owns accumulation when an application records multiple responses.

Ownership

Models Provider owns:

  • the private models.dev catalogue and its built-in cache;
  • provider and model selection;
  • provider-specific authentication and transport;
  • request-option normalization;
  • usage normalization.

The embedding application owns:

  • the provider-values dictionary;
  • credential persistence, if needed;
  • application workflows, sessions, tools, permissions, and files.

Release files for models-provider 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for models-provider 0.1.1
File Size Uploaded
models_provider-0.1.1.tar.gz 36.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for models-provider 0.1.1
File Interpreter ABI Platform
models_provider-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 78.4 kB

Release files / models_provider-0.1.1.tar.gz

Download URL models_provider-0.1.1.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ef5b03b9fded01f098e0a677ee59e5020a999f52a2b5e3d35461422e44dc2c0
BLAKE2b-256 checksum
How to use checksums
211f448897a281d8db4741e454c08bf22ff9f7674c5b252aad70f1ef8d98ef9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / models_provider-0.1.1-py3-none-any.whl

Download URL models_provider-0.1.1-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be2eb97572852d85bc24dad528b90962418155379ddf5e3bcbda515f712cf9fd
BLAKE2b-256 checksum
How to use checksums
cfb1738e7bf09010dd348bad26b220b24918a42728453bb2a5f3a424c6293055
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page