Skip to main content

MIAPI — Grounded AI Answers API

Official Python client for MIAPI — get AI-powered answers grounded in real-time web search.

Install

pip install miapi-sdk

Quick Start

from miapi import MIAPI

client = MIAPI("YOUR_API_KEY")

# Get a grounded answer with citations
result = client.answer("What is quantum computing?", citations=True)
print(result.answer)     # AI-generated answer with [1][2] markers
print(result.sources)    # List of source URLs
print(result.confidence) # 0.0 - 1.0

Features

Web-Grounded Answers

result = client.answer("Who won the last World Cup?")
print(result.answer)

Knowledge Mode — Answer From Your Data

result = client.answer(
    "What is the return policy?",
    mode="knowledge",
    knowledge="Returns accepted within 30 days with receipt..."
)
print(result.answer)

Search Only — Raw Results

sources = client.search("latest AI research papers")
for source in sources:
    print(source.title, source.url)

News Search

news = client.news("technology", num_results=5)
for article in news:
    print(article.title, article.date)

Image Search

images = client.images("golden retriever")
for img in images:
    print(img.url, img.width, img.height)

Streaming

for event in client.stream("Explain quantum computing"):
    if event['type'] == 'answer':
        print(event['content'], end='', flush=True)
    elif event['type'] == 'done':
        print(f"\nDone in {event.get('query_time_ms')}ms")

Check Usage

info = client.usage()
print(f"Used {info.queries_this_month}/{info.monthly_limit} this month")
print(f"Tier: {info.tier}")

Custom Options

result = client.answer(
    "Compare Python and Rust",
    response_format="markdown",   # text, short, json, markdown
    temperature=0.5,              # 0.0 (precise) to 1.0 (creative)
    max_tokens=800,               # Max answer length
    language="French",            # Answer in any language
    search_domains=["wikipedia.org"],  # Restrict sources
    system_prompt="Answer like a professor",
)

Error Handling

from miapi import MIAPI, MIAPIError, RateLimitError, AuthenticationError

client = MIAPI("YOUR_API_KEY")

try:
    result = client.answer("Hello")
except AuthenticationError:
    print("Bad API key")
except RateLimitError as e:
    print(f"Rate limited: {e.message}")
except MIAPIError as e:
    print(f"Error: {e.message} (HTTP {e.status_code})")

OpenAI Drop-in Replacement

MIAPI is also compatible with the OpenAI Python client:

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_MIAPI_KEY",
    base_url="https://api.miapi.uk/v1"
)

response = client.chat.completions.create(
    model="miapi-grounded",
    messages=[{"role": "user", "content": "What is AI?"}]
)
print(response.choices[0].message.content)

Get Your API Key

Sign up free at miapi.uk — 500 queries/month included.

Links

Download files

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

Source Distribution

miapi_sdk-1.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

miapi_sdk-1.0.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file miapi_sdk-1.0.2.tar.gz.

File metadata

  • Download URL: miapi_sdk-1.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for miapi_sdk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 19e6213d45995f02ddcaccad306eb83171d4bfea02313225edced33d6a20d2fb
MD5 b25cae18aabccb6613d9cf97fc296226
BLAKE2b-256 11062f1b25ae5b194d3022e2e77b9f8f6ada0a50a7e749b31b5e58192138b1e4

See more details on using hashes here.

File details

Details for the file miapi_sdk-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: miapi_sdk-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for miapi_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 034589a7e11e5d73cd8371f4361ea0192d64a19b1a86a32e5660df4267404d24
MD5 d013f5fc31ba5035d958324b63266ef1
BLAKE2b-256 244bc11512439dd67a4073239f85c99d910919fbc0153ae80b7a528ee3e0d098

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.1

2 files

1.1.0

2 files

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

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