Skip to main content

Docker Model Runner Client

A Python client for interacting with Docker Model Runner, providing a standard API interface for chat completions, embeddings, and more.

(Note :- In Code We Have Used gemma3 model please use tool callling supported model else it might possible you face issue or errors for more information please check dockerhub AI Models.)

GitHub

Installation

Install via pip:

pip install docker-model-runner

Quick Start

Synchronous Client

from docker_model_runner import Client

client = Client(base_url="http://localhost:12434/engines/v1")  # API key optional

# Chat completion
response = client.chat.completions.create(
    model="your-model",
    messages=[{"role": "user", "content": "Hello, world!"}]
)

print(response['choices'][0]['message']['content'])

Asynchronous Client

import asyncio
from docker_model_runner import AsyncClient

async def main():
    async with AsyncClient(base_url="http://localhost:12434/engines/v1") as client:  # API key optional
        response = await client.chat.completions.create(
            model="your-model",
            messages=[{"role": "user", "content": "Hello, world!"}]
        )
        print(response['choices'][0]['message']['content'])

asyncio.run(main())

Tool Calls

from docker_model_runner import Client

client = Client()  # Uses default base_url, API key optional

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"location": {"type": "string"}},
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="your-model",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools,
    tool_choice="auto"
)

# Handle tool calls
message = response['choices'][0]['message']
if message.get("tool_calls"):
    for tool_call in message["tool_calls"]:
        print(f"Tool: {tool_call['function']['name']}")

Features

  • Synchronous and asynchronous clients
  • Chat completions with streaming support
  • Embeddings
  • Tool calls with local handling
  • Compatible with standard API format

API Reference

Client

  • Client(base_url, api_key): Initialize sync client (api_key optional)
  • client.chat.completions.create(model, messages, **kwargs): Create chat completion
  • client.chat.completions.stream(model, messages, **kwargs): Stream chat completion
  • client.embeddings.create(model, input, **kwargs): Create embeddings
  • client.models.list(): List available models

AsyncClient

  • AsyncClient(base_url, api_key): Initialize async client (api_key optional)
  • Similar methods as Client, but async

Tool Choice

  • "auto": Let model decide (default)
  • "none": Don't use tools
  • "always": Force tool usage

License

MIT License - see LICENSE file for details

Metadata

Release files for docker-model-runner 0.1.2

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

Source distribution (sdist)

Source distribution for docker-model-runner 0.1.2
File Size Uploaded Provenance
docker_model_runner-0.1.2.tar.gz 17.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docker-model-runner 0.1.2
File Interpreter ABI Platform
docker_model_runner-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.4 kB

Release files / docker_model_runner-0.1.2.tar.gz

Download URL docker_model_runner-0.1.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
727452006d7a74d44c5fd50f74e56009807ca22a13515f98ed370bc6e1ab45a1
BLAKE2b-256 checksum
How to use checksums
3054c021c25a19ba5201f44fb1d252438288157c0e16c6beac50971b5213908b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / docker_model_runner-0.1.2-py3-none-any.whl

Download URL docker_model_runner-0.1.2-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14b993a6d3d3b1607001a27133deefb96a843dab4b1f6380456e0f5dfdee4d02
BLAKE2b-256 checksum
How to use checksums
f7dca9c8cbeee1363888fd30d645e7eb82c08da395fb9ed7f53285a240cab71e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for docker-model-runner 0.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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