Skip to main content

mittal-ai

Mittal Analytics' reusable AI harness. Install it as mittal-ai and import it as mittal_ai. It provides:

  • streaming, non-streaming and structured LLM responses;
  • tool-call handling 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 mittal_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.

Download files

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

Source Distribution

mittal_ai-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

mittal_ai-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file mittal_ai-0.1.0.tar.gz.

File metadata

  • Download URL: mittal_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mittal_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be72e2b5d6c4eedef939603274d36f7b82db5e33bfb894197d567dbfcdd5f067
MD5 bd805fd1ae62995ac7a82c7c9837a5de
BLAKE2b-256 7907486dedb46983674ee32148b95ab78c17bf69126e884cd88e36010e9d229b

See more details on using hashes here.

File details

Details for the file mittal_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mittal_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mittal_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aed74612e67b4290dcf4d91d5b930a8b0407a548c714723c2f8e78fdacc0edfb
MD5 d9ff691898bea5f5d116659682f38ad4
BLAKE2b-256 35eddae9955183400d59e7dfc75d2f389fbf8831029f60da91720a989585132c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page