Skip to main content

callable-ai

A callable-first AI harness from Mittal Analytics. Install it as callable-ai and import it as callable_ai. It provides:

  • streaming, non-streaming and structured LLM responses;
  • tool-call handling, reusable tool helpers and message-history repair;
  • token-cost calculation;
  • OpenRouter routing and provider preferences;
  • compatibility fixes for Chinese models; and
  • dj-evals events for model requests and tool calls.

The application keeps its API keys. The model declares which provider and base URL the harness should use:

from callable_ai import AIModel, get_client, get_structured_response
from pydantic import BaseModel


class Summary(BaseModel):
    text: str


model = AIModel(
    name="openai/gpt-5.4",
    api_key="...",
    provider="openrouter",
    base_url="https://openrouter.ai/api/v1",
    input_tokens_cost_usd=2.5,
    input_tokens_cached_cost_usd=0.25,
    output_tokens_cost_usd=15,
    output_tokens_reasoning_cost_usd=15,
)

async with get_client(model) as client:
    async for event in get_structured_response(
        client=client,
        ai_model=model,
        input=[{"role": "user", "content": "Summarise this."}],
        tools=[],
        text_format=Summary,
        reasoning_effort="low",
    ):
        print(event)

The main public entry points are get_response, get_streaming_response and get_structured_response.

Tool helpers

Use format_docstring to customize a reusable tool description and partial_with_doc to bind arguments that should not be exposed to the model:

from callable_ai import (
    ToolCallResult,
    format_docstring,
    get_streaming_response,
    partial_with_doc,
)


@format_docstring(entity="company")
def answer_question(_company_id: int, question: str) -> ToolCallResult:
    """Answer a question about a {entity}.

    Args:
        - question: Question asked by the user.
    """
    return {"content": f"{_company_id}: {question}"}


company_tool = partial_with_doc(answer_question, _company_id=123)

async for event in get_streaming_response(
    user="user-123",
    ai_model=model,
    messages=[{"role": "user", "content": "What changed?"}],
    tools=[company_tool],
    reasoning_effort="low",
):
    print(event)

company_tool exposes only question; its bound company ID stays private. Tools return ToolCallResult; async generators may yield EvalEvent updates first.

Publishing a new version

The release workflow publishes version tags to PyPI using trusted publishing. Configure callable-ai as a trusted publisher on PyPI before its first release. From a clean working tree, publish the next patch release with:

uv version --bump patch
version=$(uv version --short)

uv run pytest
uv run pre-commit run --all-files

git add pyproject.toml uv.lock
git commit -m "Release version $version"
git tag -a "v$version" -m "v$version"
git push origin main "v$version"

The tag must match the version in pyproject.toml, with a v prefix. Use --bump minor or --bump major when appropriate. PyPI versions are immutable, so every release needs a new version.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

callable_ai-0.1.5.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

callable_ai-0.1.5-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file callable_ai-0.1.5.tar.gz.

File metadata

  • Download URL: callable_ai-0.1.5.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for callable_ai-0.1.5.tar.gz
Algorithm Hash digest
SHA256 537abde580de826dd4da81c768f0838f855bbf660dc1134adc1a75828e04b057
MD5 b6a7d83a84181321a86c89354d1ac3fd
BLAKE2b-256 e7393709260a8812bf0b7c2ac02e4b6d321826b7336cbea9c85daeca9e2e4426

See more details on using hashes here.

Provenance

The following attestation bundles were made for callable_ai-0.1.5.tar.gz:

Publisher: release.yml on Mittal-Analytics/mittal-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file callable_ai-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: callable_ai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for callable_ai-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 49772186c42bb3b7e883069f8a1e042efbb54ea2162d26a6960e49fa5674085c
MD5 b951b8a0d5da74df72abead81377da1b
BLAKE2b-256 d75d0d222a5e819b419973c1b1f908edf4807d1cffe42b1b72fda9996fcd25a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for callable_ai-0.1.5-py3-none-any.whl:

Publisher: release.yml on Mittal-Analytics/mittal-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

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