Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 15
  • Releases: 21
Created 11 months ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

OpenAI Model Registry

PyPI version Python Versions CI Status codecov License: MIT

A Python package that provides information about OpenAI models and validates parameters before API calls.

📚 View the Documentation 🤖 AI Assistant Documentation - LLM-optimized reference following llmstxt.org

Why Use OpenAI Model Registry?

OpenAI's models have different context-window sizes, parameter ranges, and feature support. If you guess wrong, the API returns an error—often in production.

OpenAI Model Registry keeps an up-to-date, local catalog of every model's limits and capabilities, letting you validate calls before you send them.

Typical benefits:

  • Catch invalid temperature, top_p, and max_tokens values locally.
  • Swap models confidently by comparing context windows and features.
  • Work fully offline—perfect for CI or air-gapped environments.

What This Package Does

  • Helps you avoid invalid API calls by validating parameters ahead of time
  • Provides accurate information about model capabilities (context windows, token limits)
  • Handles model aliases and different model versions
  • Works offline with locally stored model information
  • Keeps model information up-to-date with optional updates
  • Programmatic model cards: structured access to each model's capabilities, parameters, pricing (including per-image tiers), and deprecation metadata (OpenAI and Azure providers)
  • Coverage and freshness: includes all OpenAI models as of 2025-08-16; pricing and data are kept current automatically via CI using ostruct

Installation

Core Library (Recommended)

bash pip install openai-model-registry

With CLI Tools

bash pip install openai-model-registry[cli]

The core library provides all programmatic functionality. Add the [cli] extra if you want to use the omr command-line tools.

💡 Which installation should I choose?

  • Core only (pip install openai-model-registry) - Perfect for programmatic use in applications, scripts, or libraries
  • With CLI (pip install openai-model-registry[cli]) - Adds command-line tools for interactive exploration and debugging

Simple Example

```python from openaimodelregistry import ModelRegistry

Get information about a model

registry = ModelRegistry.getdefault() model = registry.getcapabilities("gpt-4o")

Access model limits

print(f"Context window: {model.contextwindow} tokens") print(f"Max output: {model.maxoutput_tokens} tokens")

Expected output: Context window: 128000 tokens

Max output: 16384 tokens

Check if parameter values are valid

model.validateparameter("temperature", 0.7) # Valid - no error try: model.validateparameter("temperature", 3.0) # Invalid - raises ValueError except ValueError as e: print(f"Error: {e}")

Expected output: Error: Parameter 'temperature' must be between 0 and 2...

Check model features

if model.supports_structured: print("This model supports Structured Output")

Expected output: This model supports Structured Output

```

➡️ Keeping it fresh: run openai-model-registry-update (CLI) or registry.refresh_from_remote() whenever OpenAI ships new models.

🔵 Azure OpenAI Users: If you're using Azure OpenAI endpoints, be aware of platform-specific limitations, especially for web search capabilities. See our Azure OpenAI documentation for guidance.

Practical Use Cases

Validating Parameters Before API Calls

```python import openai from openaimodelregistry import ModelRegistry

Initialize registry and client

registry = ModelRegistry.getdefault() client = openai.OpenAI() # Requires OPENAIAPI_KEY environment variable

def callopenai(model, messages, **params): # Validate parameters before making API call capabilities = registry.getcapabilities(model) for paramname, value in params.items(): capabilities.validateparameter(param_name, value)

# Now make the API call
return client.chat.completions.create(model=model, messages=messages, **params)

Example usage

messages = [{"role": "user", "content": "Hello!"}] response = callopenai("gpt-4o", messages, temperature=0.7, maxtokens=100)

Expected output: Successful API call with validated parameters

```

Managing Token Limits

```python from openaimodelregistry import ModelRegistry

Initialize registry

registry = ModelRegistry.get_default()

def truncateprompt(prompt, maxtokens): """Simple truncation function (you'd implement proper tokenization)""" # This is a simplified example - use tiktoken for real tokenization words = prompt.split() if len(words) <= maxtokens: return prompt return " ".join(words[:maxtokens])

def prepareprompt(modelname, prompt, maxoutput=None): capabilities = registry.getcapabilities(model_name)

# Use model's max output if not specified
max_output = max_output or capabilities.max_output_tokens

# Calculate available tokens for input
available_tokens = capabilities.context_window - max_output

# Ensure prompt fits within available tokens
return truncate_prompt(prompt, available_tokens)

Example usage

longprompt = "This is a very long prompt that might exceed token limits..." safeprompt = prepareprompt("gpt-4o", longprompt, max_output=1000)

Expected output: Truncated prompt that fits within token limits

```

Key Features

  • Model Information: Get context window size, token limits, and supported features
  • Parameter Validation: Check if parameter values are valid for specific models
  • Version Support: Works with date-based models (e.g., "o3-mini-2025-01-31")
  • Offline Usage: Functions without internet using local registry data
  • Updates: Optional updates to keep model information current

Command Line Usage

OMR CLI

The omr CLI provides comprehensive tools for inspecting and managing your model registry.

Note: CLI tools require the [cli] extra: pip install openai-model-registry[cli]

```bash

List all models

omr models list

Show data source paths

omr data paths

Check for updates

omr update check

Get detailed model info

omr models get gpt-4o ```

See the CLI Reference for complete documentation.

Note on updates: omr update apply and omr update refresh write updated data files to your user data directory by default (or OMR_DATA_DIR if set). The OMR_MODEL_REGISTRY_PATH environment variable is a read-only override for loading models.yaml and is never modified by update commands.

Legacy Update Command

Update your local registry data:

bash openai-model-registry-update

Configuration

The registry uses local files for model information:

```text

Default locations (XDG Base Directory spec)

Linux: ~/.local/share/openai-model-registry/ macOS: ~/Library/Application Support/openai-model-registry/ Windows: %LOCALAPPDATA%\openai-model-registry\ ```

You can specify custom locations:

```python import os

Use custom registry files

os.environ["OMRMODELREGISTRYPATH"] = "/path/to/custom/models.yaml" os.environ["OMRPARAMETERCONSTRAINTSPATH"] = ( "/path/to/custom/parameter_constraints.yml" )

Then initialize registry

from openaimodelregistry import ModelRegistry

registry = ModelRegistry.get_default() ```

Environment variables

text OMR_DATA_DIR # Override user data dir where updates are written OMR_MODEL_REGISTRY_PATH # Read-only override for models.yaml load path OMR_DISABLE_DATA_UPDATES # Set to 1/true to disable automatic data update checks

Documentation

For more details, see:

Development

```bash

Install dependencies with CLI tools (requires Poetry)

poetry install --extras cli

Run tests

poetry run pytest

Run linting

poetry run pre-commit run --all-files ```

Next Steps

Contributing

We 💜 external contributions! Start with CONTRIBUTING.md and our Code of Conduct.

Need Help?

Open an issue or start a discussion—questions, ideas, and feedback are welcome!

License

MIT License - See LICENSE for details.

Owner

  • Name: Yaniv Golan
  • Login: yaniv-golan
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: "Golan"
    given-names: "Yaniv"
    email: "yaniv@golan.name"
title: "OpenAI Model Registry"
version: 1.0.0
date-released: 2025-08-13
url: "https://github.com/yaniv-golan/openai-model-registry"
repository-code: "https://github.com/yaniv-golan/openai-model-registry"
license: MIT
abstract: >-
  A typed Python library and CLI for programmatic model cards,
  parameter validation, and capabilities/pricing metadata for OpenAI models
  (with Azure support). Includes inline parameter constraints, provider
  overrides, web-search billing (dataclass), unified pricing (with per-image
  tiers), input/output modalities, and a rich `omr` CLI for listing, querying,
  filtering, and debugging registry data. Pricing is kept up-to-date
  automatically via CI using the `ostruct` tool. Suitable for both application
  code and CI/CD use.
keywords:
  - openai
  - azure
  - llm
  - GenAI

GitHub Events

Total
  • Release event: 20
  • Delete event: 36
  • Issue comment event: 65
  • Push event: 145
  • Pull request event: 62
  • Create event: 70
Last Year
  • Release event: 20
  • Delete event: 36
  • Issue comment event: 65
  • Push event: 145
  • Pull request event: 62
  • Create event: 70

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 42
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 1.62
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 41
Past Year
  • Issues: 0
  • Pull requests: 42
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 1.62
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 41
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (84)
  • yaniv-golan (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 3,246 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 14
  • Total maintainers: 1
pypi.org: openai-model-registry

Registry for OpenAI models with capability and parameter validation

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 3,246 Last month
Rankings
Dependent packages count: 9.5%
Average: 31.4%
Dependent repos count: 53.3%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/cross-platform-test.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • snok/install-poetry v1 composite
.github/workflows/data-release-enhanced.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • dorny/paths-filter v3 composite
  • softprops/action-gh-release v2 composite
.github/workflows/ostruct-pricing.yml actions
  • EndBug/add-and-commit v9 composite
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • snok/install-poetry v1 composite
.github/workflows/release.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
  • snok/install-poetry v1 composite
  • softprops/action-gh-release v2 composite
.github/workflows/update-pricing.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • peter-evans/create-pull-request v5 composite
  • snok/install-poetry v1 composite
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • snok/install-poetry v1 composite
poetry.lock pypi
  • annotated-types 0.7.0
  • backports-tarfile 1.2.0
  • black 23.3.0
  • build 1.2.2.post1
  • certifi 2025.1.31
  • cffi 1.17.1
  • cfgv 3.4.0
  • charset-normalizer 3.4.1
  • click 8.1.8
  • colorama 0.4.6
  • cryptography 43.0.3
  • distlib 0.3.9
  • docutils 0.21.2
  • exceptiongroup 1.2.2
  • filelock 3.18.0
  • flake8 6.1.0
  • flake8-pyproject 1.2.3
  • id 1.5.0
  • identify 2.6.9
  • idna 3.10
  • importlib-metadata 8.6.1
  • iniconfig 2.0.0
  • isort 5.13.2
  • jaraco-classes 3.4.0
  • jaraco-context 6.0.1
  • jaraco-functools 4.1.0
  • jeepney 0.9.0
  • keyring 25.6.0
  • markdown-it-py 3.0.0
  • mccabe 0.7.0
  • mdurl 0.1.2
  • more-itertools 10.6.0
  • mypy 1.15.0
  • mypy-extensions 1.0.0
  • nh3 0.2.21
  • nodeenv 1.9.1
  • packaging 24.2
  • pathspec 0.12.1
  • platformdirs 4.3.6
  • pluggy 1.5.0
  • pre-commit 3.8.0
  • pycodestyle 2.11.1
  • pycparser 2.22
  • pydantic 2.10.6
  • pydantic-core 2.27.2
  • pyflakes 3.1.0
  • pygments 2.19.1
  • pyproject-hooks 1.2.0
  • pytest 8.3.5
  • pytest-mock 3.14.0
  • pywin32-ctypes 0.2.3
  • pyyaml 6.0.2
  • readme-renderer 44.0
  • requests 2.32.3
  • requests-toolbelt 1.0.0
  • rfc3986 2.0.0
  • rich 13.9.4
  • ruff 0.3.7
  • secretstorage 3.3.3
  • tomli 2.2.1
  • twine 6.1.0
  • types-pyyaml 6.0.12.20241230
  • types-requests 2.32.0.20250306
  • typing-extensions 4.12.2
  • urllib3 2.3.0
  • virtualenv 20.29.3
  • zipp 3.21.0
pyproject.toml pypi
  • black 23.3.0 develop
  • build ^1.2.2.post1 develop
  • flake8 ^6.0 develop
  • flake8-pyproject ^1.2.3 develop
  • isort ^5.13 develop
  • mypy ^1.0 develop
  • pre-commit ^3.6.0 develop
  • pytest ^8.3.4 develop
  • pytest-mock ^3.14.0 develop
  • ruff ^0.3.6 develop
  • twine ^6.0.1 develop
  • types-pyyaml ^6.0.12.20241230 develop
  • types-requests ^2.31.0.20240125 develop
  • PyYAML ^6.0.1
  • platformdirs ^4.3.6
  • pydantic ^2.6.3
  • python >=3.9,<4.0
  • requests ^2.31.0
  • typing-extensions ^4.9.0
.github/workflows/codecov.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v5 composite
  • snok/install-poetry v1 composite
.github/workflows/codeql.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/coverage.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
  • snok/install-poetry v1 composite
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • peaceiris/actions-gh-pages v3 composite
  • snok/install-poetry v1 composite
.github/workflows/publish-poetry.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • snok/install-poetry v1 composite
.github/workflows/release-drafter.yml actions
  • release-drafter/release-drafter v5 composite