Skip to main content

LiteLLM Apple Foundation Models (custom provider)

LiteLLM custom provider for Apple's on-device Foundation Models (macOS 26+ with Apple Intelligence).

Pre-requisites

  • macOS 26.0+ (Sequoia) with Apple Intelligence enabled
  • Python 3.9+

Install

pip install -e .

Requires Python 3.9+ and apple-foundation-models (only available on macOS).

Quick start

import litellm
from litellm_apple_foundation_models import (
    register_apple_foundation_models_provider,
)

# Register the provider once in your process
register_apple_foundation_models_provider()

resp = litellm.completion(
    model="apple_foundation_models/system",
    messages=[{"role": "user", "content": "Hello from macOS"}],
)
print(resp.choices[0].message.content)

Streaming and async are supported:

resp = litellm.completion(
    model="apple_foundation_models/system",
    messages=[{"role": "user", "content": "Write a haiku about objc"}],
    stream=True,
)
for chunk in resp:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Async:

import asyncio
from litellm import acompletion

async def main():
    response = await acompletion(
        model="apple_foundation_models/system",
        messages=[{"role": "user", "content": "Hello, how are you?"}],
        max_tokens=100,
    )
    print(response)

asyncio.run(main())

Async + streaming:

import asyncio
from litellm import acompletion

async def main():
    response = await acompletion(
        model="apple_foundation_models/system",
        messages=[{"role": "user", "content": "Write a short poem about AI"}],
        stream=True,
        max_tokens=200,
    )

    async for chunk in response:
        if chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="", flush=True)

asyncio.run(main())

Tool calling

from litellm import completion
from litellm_apple_foundation_models import register_apple_foundation_models_provider

register_apple_foundation_models_provider()

def get_weather(location: str, units: str = "celsius") -> str:
    """Get the current weather for a location."""
    return f"Weather in {location}: 22°{units[0].upper()}, sunny"

def calculate(a: int, b: int) -> int:
    """Add two numbers together."""
    return a + b

response = completion(
    model="apple_foundation_models/system",
    messages=[{"role": "user", "content": "What's the weather in Paris and what's 5 plus 7?"}],
    tool_functions=[get_weather, calculate],
    max_tokens=200,
)

if response.choices[0].message.tool_calls:
    for tool_call in response.choices[0].message.tool_calls:
        print(f"Tool: {tool_call.function.name}({tool_call.function.arguments})")

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

You can also pass OpenAI-style schemas via tools=[...] and map implementations with tool_functions.

Structured output

Pydantic:

from pydantic import BaseModel
from litellm import completion

class Person(BaseModel):
    name: str
    age: int
    city: str

response = completion(
    model="apple_foundation_models/system",
    messages=[{"role": "user", "content": "Extract person info: Alice is 30 and lives in Paris."}],
    response_format=Person,
    max_tokens=150,
)
print(response.choices[0].message.content)

JSON schema:

import json
from litellm import completion

schema = {
    "type": "object",
    "properties": {
        "answer": {"type": "string"},
        "confidence": {"type": "number"},
    },
    "required": ["answer"],
}

response = completion(
    model="apple_foundation_models/system",
    messages=[{"role": "user", "content": "Is the sky blue? Return JSON with answer and confidence (0-1)."}],
    response_format={"type": "json_schema", "json_schema": {"schema": schema}},
    max_tokens=100,
)
print(response.choices[0].message.content)

Supported parameters

  • temperature: float
  • max_tokens: int
  • stream: bool
  • tools / tool_functions
  • response_format (Pydantic model or JSON schema)

How it works

  • Uses LiteLLM's CustomLLM interface to avoid touching LiteLLM core.
  • Registers itself via litellm.custom_provider_map so calls to litellm.completion with model="apple_foundation_models/*" are routed here.

Development

  • Tests live under tests/ (mirrors the coverage from the original core PR).
  • To run tests locally:
pip install -e .[dev]
pytest

Metadata

Release files for litellm-apple-foundation-models 0.1.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 litellm-apple-foundation-models 0.1.0
File Size Uploaded Provenance Actions
litellm_apple_foundation_models-0.1.0.tar.gz 200.4 kB With provenance Details for litellm_apple_foundation_models-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for litellm-apple-foundation-models 0.1.0
File Interpreter ABI Platform Actions
litellm_apple_foundation_models-0.1.0-py3-none-any.whl Python 3 none any Details for litellm_apple_foundation_models-0.1.0-py3-none-any.whl

Total release size: 212.6 kB

Release files / litellm_apple_foundation_models-0.1.0.tar.gz

Download URL litellm_apple_foundation_models-0.1.0.tar.gz
Size 200.4 kB
Tags Source
SHA-256 checksum
How to use checksums
54fa86dccf47818e9bb1b350cf9005510b4be8523904e1703c725779e2545820
BLAKE2b-256 checksum
How to use checksums
db43ac7598da51bc889b1222c27d7ee696ff1c13b49efeed9a9ef1c4b61ab79b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 21, 2025.

Transparency log

Release files / litellm_apple_foundation_models-0.1.0-py3-none-any.whl

Download URL litellm_apple_foundation_models-0.1.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bb0bc08666a88c58cdc9b9a02ea0229ec5350a4d3730999b8168c03f00cfda9
BLAKE2b-256 checksum
How to use checksums
6d3ea45aed68d1c0afbb82c9eafe5d6365a57498d5809cb34696a8d89cec1216
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 21, 2025.

Transparency log

Security for litellm-apple-foundation-models 0.1.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for litellm_apple_foundation_models-0.1.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 21, 2025.

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

0.1.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