Skip to main content

LLMling-models

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Discussions 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 Claude Code model, 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)
claude ClaudeCodeModel (claude-agent-sdk)
codemode fastmcp, for the MCP tool bridge (llmling_models.tool_bridge)
anthropic-max Anthropic Claude Max/Pro OAuth provider
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:, anthropic-max:, claude-code:, input, remote_model:, remote_input:, import:, test:) and comma-separated fallback chains.
  • Models: InputModel, UserSelectModel, DelegationMultiModel, AugmentedModel, RemoteInputModel, RemoteProxyModel, ClaudeCodeModel, function_to_model().
  • Providers: GitHub Copilot, LM Studio, Requesty, Moondream, OpenCode Zen, Anthropic Max OAuth.
  • 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?")

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.

Claude Code Model

Delegates to the Claude Code CLI via the Claude Agent SDK (claude extra; authenticate with claude login). Claude Code's own tools are enabled per agent as pydantic-ai native tools:

from pydantic_ai import Agent
from pydantic_ai.capabilities import NativeTool
from llmling_models import ClaudeCodeGlobTool, ClaudeCodeModel, ClaudeCodeReadTool

model = ClaudeCodeModel(model="sonnet", cwd="/path/to/project", max_turns=10)

# Without native tools, Claude has no tool access
agent = Agent(model)

# With native tools
agent = Agent(
    model,
    capabilities=[NativeTool(ClaudeCodeGlobTool()), NativeTool(ClaudeCodeReadTool())],
)
result = await agent.run("What files are in the current directory?")

Available tools: ClaudeCodeReadTool, ClaudeCodeWriteTool, ClaudeCodeEditTool, ClaudeCodeBashTool, ClaudeCodeGlobTool, ClaudeCodeGrepTool, ClaudeCodeWebSearchTool, ClaudeCodeWebFetchTool, ClaudeCodeTaskTool, ClaudeCodeNotebookEditTool. claude_code_all_tools() and claude_code_read_only_tools() return ready-made lists.

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, anthropic-max, 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

# OAuth logins for subscription-based providers
llmling-models copilot-auth
llmling-models anthropic-auth
llmling-models gemini-auth
llmling-models antigravity-auth

License

MIT

Metadata

Release files for llmling-models 1.7.3

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.7.3
File Size Uploaded Provenance Actions
llmling_models-1.7.3.tar.gz 98.6 kB With provenance Details for llmling_models-1.7.3.tar.gz

Built distribution (wheel)

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

Total release size: 228.1 kB

Release files / llmling_models-1.7.3.tar.gz

Download URL llmling_models-1.7.3.tar.gz
Size 98.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9750bb32a87f6e23dc7f563f02282b63f2dcfe5bfc11f086505598a5e4cde35e
BLAKE2b-256 checksum
How to use checksums
ef2f8ae4a82befa753ba43a8bb53f7014519856a959672536eed81c23941ba39
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 22, 2026.

Transparency log

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

Download URL llmling_models-1.7.3-py3-none-any.whl
Size 129.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfaaf2c0c7bb509ba5d74912a48dccf51a2b4ec58b1c61a5cf4c4e1662a0f605
BLAKE2b-256 checksum
How to use checksums
2a0454ef1b6fef7f2bfc90aa7e98ff9bde15bef40204ffb6d0bc95e2efe0825f
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 22, 2026.

Transparency log

Security for llmling-models 1.7.3

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.7.3.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 22, 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.7.3 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