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


conversation_id = "session-1"
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,
    input_tokens_cache_write_cost_usd=2.5,
    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",
        prompt_cache_key=conversation_id,
    ):
        print(event)

get_response, get_streaming_response and get_structured_response reuse the required prompt_cache_key for tool-call follow-ups and OpenRouter routing.

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)
conversation_id = "session-1"

async for event in get_streaming_response(
    prompt_cache_key=conversation_id,
    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.

Metadata

Release files for callable-ai 0.2.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 callable-ai 0.2.0
File Size Uploaded
callable_ai-0.2.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for callable-ai 0.2.0
File Interpreter ABI Platform
callable_ai-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / callable_ai-0.2.0.tar.gz

Download URL callable_ai-0.2.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fd9fe6f4c83ffb5a18d6936d84d8607bce42242b741abcc6ad52e3570107661e
BLAKE2b-256 checksum
How to use checksums
a0be86734c0828bda1fb6c98b15d775206b88f72b98b3fd4866abdcf5d84d053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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}

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 Oct 8, 2026.

Transparency log

Release files / callable_ai-0.2.0-py3-none-any.whl

Download URL callable_ai-0.2.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ad75b6a5a8609d30e678d2074562e73ad96391388bac4536888d9b4ef4aa25b
BLAKE2b-256 checksum
How to use checksums
7ac3091748a2e37b8db455135acb57c9cbef57907443e6211ecebd69c3ef937b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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}

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 Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release 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