Skip to main content

LLMling-models

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status PyUp

Extra pydantic-ai models, providers and toolsets: human-in-the-loop models, model routing, prompt augmentation, remote models, a "code mode" toolset and an extended infer_model(). Built for AgentPool, but everything works with plain pydantic-ai.

Documentation: https://phil65.github.io/LLMling-models/

Installation

uv add llmling-models

Optional extras:

Extra Enables
server OpenAI-compatible server and the llmling-models CLI
remote Remote model / remote input servers (FastAPI, websockets)
codemode fastmcp, for the MCP tool bridge (llmling_models.tool_bridge)
default The full pydantic-ai package with all of its providers

Quickstart

from pydantic_ai import Agent
from llmling_models import infer_model

# Drop-in replacement for pydantic-ai's model inference, with extra prefixes
model = infer_model("test:Hello from llmling-models")
agent = Agent(model)
result = agent.run_sync("Say hi")
print(result.output)  # Hello from llmling-models

Features

  • Extended infer_model(): extra prefixes (openrouter:, grok:, deepseek:, perplexity:, copilot:, lm-studio:, zen:, input, remote_model:, remote_input:, import:, test:) and comma-separated fallback chains.
  • Models: InputModel, UserSelectModel, DelegationMultiModel, AugmentedModel, RemoteInputModel, RemoteProxyModel, function_to_model().
  • Providers: GitHub Copilot, LM Studio, Requesty, Moondream, OpenCode Zen.
  • CodeModeToolset: exposes tools as a Python API the model can script against.
  • Config models: llmling_models_config holds pydantic configs (StringModelConfig, OpenAIModelConfig, AnthropicModelConfig, ...) with a get_model() factory.
  • CLI: OpenAI-compatible API server and OAuth logins.

Extended infer_model

from llmling_models import infer_model

model = infer_model("openai:gpt-4o")  # standard pydantic-ai ids still work
model = infer_model("openrouter:anthropic/claude-sonnet-4.5")  # OPENROUTER_API_KEY
model = infer_model("grok:grok-4")  # X_AI_API_KEY or GROK_API_KEY
model = infer_model("deepseek:deepseek-chat")  # DEEPSEEK_API_KEY
model = infer_model("perplexity:sonar")  # PERPLEXITY_API_KEY
model = infer_model("copilot:gpt-4o-mini")  # GitHub Copilot token
model = infer_model("lm-studio:model-name")  # local LM Studio server

model = infer_model("input")  # human types the answer
model = infer_model("remote_model:ws://host:8000/v1/completion/stream")
model = infer_model("remote_input:ws://host:8000/v1/chat/stream")
model = infer_model("import:my_package.models:MyModel")  # import a Model from a path
model = infer_model("test:Custom response")  # TestModel with fixed output

# Fallback chain: tries models in order
model = infer_model("openai:gpt-4o,anthropic:claude-sonnet-4-5")
Provider Environment variable
OpenRouter OPENROUTER_API_KEY
Grok (X.AI) X_AI_API_KEY or GROK_API_KEY
DeepSeek DEEPSEEK_API_KEY
Perplexity PERPLEXITY_API_KEY
Copilot GITHUB_COPILOT_API_KEY (or llmling-models copilot-auth)
LM Studio LM_STUDIO_BASE_URL (default http://localhost:1234/v1)
Requesty REQUESTY_API_KEY
OpenCode Zen OPENCODE_API_KEY
OpenAI OPENAI_API_KEY

Models

Input Model

Delegates responses to a human, for testing, debugging or hybrid human-AI workflows:

from pydantic_ai import Agent
from llmling_models import InputModel

model = InputModel(
    prompt_template="Question: {prompt}",
    show_system=True,
    input_prompt="Your answer: ",
)
agent = Agent(model=model, system_prompt="You are helping test an input model.")
result = await agent.run("What's your favorite color?")
print(result.output)

Custom input sources can be plugged in via the handler argument (see llmling_models.models.input_model.input_handlers).

User Select Model

Lets the user pick which model answers each prompt:

from pydantic_ai import Agent
from llmling_models import UserSelectModel

model = UserSelectModel(models=["openai:gpt-4o-mini", "anthropic:claude-haiku-4-5"])
agent = Agent(model)
result = await agent.run("What is the meaning of life?")

Delegation Model

A selector model picks the most suitable model for each prompt:

from pydantic_ai import Agent
from llmling_models import DelegationMultiModel

model = DelegationMultiModel(
    selector_model="openai:gpt-4o-mini",
    models=["openai:gpt-4o", "openai:gpt-4o-mini"],
    model_descriptions={
        "openai:gpt-4o": "Complex reasoning, math and coding tasks",
        "openai:gpt-4o-mini": "Simple queries and chat",
    },
    selection_prompt="Select the most appropriate model for the task.",
)
agent = Agent(model)
result = await agent.run("Solve this complex mathematical proof...")

Augmented Model

Pre- and post-processes prompts with auxiliary models:

from pydantic_ai import Agent
from llmling_models.models import AugmentedModel
from llmling_models.models.augmented import PrePostPromptConfig

model = AugmentedModel(
    main_model="openai:gpt-4o",
    pre_prompt=PrePostPromptConfig(
        text="Expand this question: {input}", model="openai:gpt-4o-mini"
    ),
    post_prompt=PrePostPromptConfig(
        text="Summarize this response concisely: {output}", model="openai:gpt-4o-mini"
    ),
)
agent = Agent(model)
result = await agent.run("What is AI?")

When streaming (agent.run_stream(), agent.iter()), only the pre-prompt is applied: the main model's stream is passed through unchanged, so the post-prompt is skipped.

Remote Input and Remote Proxy Models

Forward requests to a remote human operator (RemoteInputModel) or to a model served elsewhere (RemoteProxyModel), over WebSocket (streaming) or REST. Requires the remote extra.

from pydantic_ai import Agent
from llmling_models.models import RemoteInputModel

model = RemoteInputModel(url="ws://operator:8000/v1/chat/stream", api_key="your-api-key")
agent = Agent(model)
result = await agent.run("What's the meaning of life?")

Serving a pydantic-ai model for RemoteProxyModel:

from llmling_models.models.remote_model.server import ModelServer

server = ModelServer(model="openai:gpt-4o-mini", api_key="your-secret-key")
server.run(host="0.0.0.0", port=8000)

The matching operator server for RemoteInputModel lives in llmling_models.models.remote_input.server.

CodeModeToolset

CodeModeToolset wraps other toolsets and exposes a single Python execution tool in which all wrapped tools are available as async functions. LLMs are good at writing code, so chaining several tool calls in one script is often more reliable and cheaper than classic tool calling (background).

import webbrowser

from pydantic_ai import Agent
from pydantic_ai.toolsets.function import FunctionToolset
from llmling_models import CodeModeToolset

browser_toolset = FunctionToolset(tools=[webbrowser.open])
code_toolset = CodeModeToolset(toolsets=[browser_toolset])

agent = Agent(model="openai:gpt-4o-mini", toolsets=[code_toolset])
async with agent:
    result = await agent.run("Open google.com in a new tab")
    # The model writes e.g.: await open("https://google.com", new=2)

Providers

pydantic-ai Provider implementations for OpenAI-compatible services:

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from llmling_models.providers.lm_studio_provider import LMStudioProvider

provider = LMStudioProvider(base_url="http://localhost:1234/v1")
model = OpenAIChatModel("model-name", provider=provider)  # a model loaded in LM Studio
agent = Agent(model)

llmling_models.providers.infer_provider() extends pydantic-ai's provider lookup with copilot, grok, perplexity, lm-studio, requesty, zen and opencode-go, and falls back to pydantic-ai for everything else.

Model configs

llmling_models_config is a lightweight package of pydantic models for declaring models in config files:

from llmling_models_config import StringModelConfig

config = StringModelConfig(identifier="openai:gpt-4o-mini", temperature=0.2)
model = config.get_model()
settings = config.get_model_settings()

CLI

With the server extra installed:

# OpenAI-compatible API server
llmling-models serve --model gpt4=openai:gpt-4o --port 8000 --api-key secret
llmling-models serve --config models.yml
llmling-models serve --auto-discover

# GitHub Copilot device-flow login
llmling-models copilot-auth

Anthropic does not permit other tools to log in with a Claude plan (Claude Code legal and compliance), so there is no Claude Pro/Max login here; use an Anthropic API key.

License

MIT

Metadata

Release files for llmling-models 1.9.0

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

Source distribution (sdist)

Source distribution for llmling-models 1.9.0
File Size Uploaded Provenance Actions
llmling_models-1.9.0.tar.gz 76.0 kB With provenance Details for llmling_models-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llmling-models 1.9.0
File Interpreter ABI Platform Actions
llmling_models-1.9.0-py3-none-any.whl Python 3 none any Details for llmling_models-1.9.0-py3-none-any.whl

Total release size: 174.5 kB

Release files / llmling_models-1.9.0.tar.gz

Download URL llmling_models-1.9.0.tar.gz
Size 76.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6a3617097398ff4c7c073817ad0e686fdee9c862c3aafe35d6d1b1ff5f894b6e
BLAKE2b-256 checksum
How to use checksums
5918722b1095ba4fbc5360fe931c0e540f2e0406ac7f15923a3f93672210217e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / llmling_models-1.9.0-py3-none-any.whl

Download URL llmling_models-1.9.0-py3-none-any.whl
Size 98.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d15aee7d02be66ac1ce062f575ec77831adc19320f2e2fa036c4c1cb3093c49
BLAKE2b-256 checksum
How to use checksums
29f38cb5c1325a2310ba469f738a31a69c0603f4a98a324aaa551a2866593d0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Security for llmling-models 1.9.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llmling_models-1.9.0.tar.gz

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 Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files Full provenance

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