MIAPI — Grounded Web Answers について
MIAPIは、リアルタイムのウェブ検索に基づき出典付きのAI回答を返すAPIです。検索結果、ニュース、画像も取得でき、MCPサーバー経由でAIアシスタントから利用できます。
主な機能
- 01出典付きウェブ検索回答の生成
- 02指定テキストに基づく回答
- 03ウェブ検索結果の取得
- 04ニュースと画像の検索
- 05回答のストリーミング出力
- 06API利用状況の確認
活用シーン
- 01質問を調べて出典を確認
- 02返品ポリシーに基づく問い合わせ回答
- 03新しい研究論文の検索結果取得
- 04テーマに関するニュースや画像の検索
MCP 対応
MIAPIはMCPサーバーを提供し、ウェブ回答、ウェブ検索、ニュース検索、画像検索、利用状況確認のツールをクライアントに公開します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
MIAPI — グラウンディングされた AI 回答 API
MIAPI の公式 Python クライアントです。リアルタイムのウェブ検索に基づいた AI 回答を取得できます。
インストール
pip install miapi-sdk
クイックスタート
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
機能
ウェブ検索に基づいた回答
result = client.answer("Who won the last World Cup?")
print(result.answer)
ナレッジモード — データから回答
result = client.answer(
"What is the return policy?",
mode="knowledge",
knowledge="Returns accepted within 30 days with receipt..."
)
print(result.answer)
検索のみ — 生の検索結果
sources = client.search("latest AI research papers")
for source in sources:
print(source.title, source.url)
ニュース検索
news = client.news("technology", num_results=5)
for article in news:
print(article.title, article.date)
画像検索
images = client.images("golden retriever")
for img in images:
print(img.url, img.width, img.height)
ストリーミング
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")
使用状況の確認
info = client.usage()
print(f"Used {info.queries_this_month}/{info.monthly_limit} this month")
print(f"Tier: {info.tier}")
カスタムオプション
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",
)
エラー処理
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 のドロップイン置き換え
MIAPI は OpenAI Python クライアントにも対応しています。
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)
API キーの取得
miapi.uk で無料登録できます。毎月 500 件のクエリが含まれています。
リンク
Claude Desktop、Cursor、または Windsurf から利用する(MCP)
MIAPI には MCP サーバーが付属しているため、コードを書かなくても AI アシスタントでウェブを検索し、実際の引用を含む回答を取得できます。
pip install "miapi-sdk[mcp]"
次に、アシスタントの MCP 設定に追加します。
{
"mcpServers": {
"miapi": {
"command": "miapi-mcp",
"env": { "MIAPI_API_KEY": "your_key_here" }
}
}
}
利用できるツール:web_answer、web_search、news_search、image_search、check_usage。
https://miapi.uk でキーを取得できます。無料プランもあります。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。