需要自备对应厂商的 API Key 才能实际调用模型;示例默认用 anthropic/claude-sonnet-4-5,换模型要改 provider/model 字符串;本地开发网站需另装 Bun
uv add "mirascope[all]"README 未说明;调用的是云端 LLM API,本地无需 GPU 或显存
用统一接口调用各家前沿 LLM 的 Python 库,号称反框架,轻量不绑架你的代码
用 Python 和 TypeScript 统一调用各家大模型,把提示词、工具调用和结构化输出封装成轻量模块,避免被重型框架绑死。
核心能力
- 用 @llm.call 装饰器把函数直接变成 LLM 调用
- 传 format=Pydantic 模型即可拿到结构化输出并 parse
- 用 @llm.tool 定义工具,循环 resume 执行工具调用构建 Agent
- 模型用 provider/model 字符串指定,如 anthropic/claude-sonnet-4-5
- 同一仓库同时提供 Python 与 TypeScript 实现
容易踩的坑
- v2.8.2最新正式版2026-10-22 · 2026-10-22 22:54 UTC
Fixes
- Keep OpenAI streamed tool calls separate when providers omit or reuse their index; handle failed and incomplete Responses streams, refusals, and strict structured output more reliably.
- Improve Anthropic error and finish-reason mapping, and prevent a tool cache breakpoint from leaking into later requests.
- Correct Google streamed usage totals and tool-use prompt token accounting; handle empty tool arguments and image refusals.
- Refresh MiniMax Flash model suggestions and improve context-length finish reasons in instrumentation.
Thanks to @pcbeingused333 and everyone who contributed reviews and fixes.
TypeScript remains an alpha release (
2.8.2-alpha.0). - v2.8.12026-10-20 · 2026-10-20 19:06 UTC
查看更新说明
Fixes
- Correct Anthropic streamed input token totals to include cache reads and writes.
- Keep cumulative and partial stream usage events accurate in Python and TypeScript.
Thanks to @pcbeingused333 for reporting and starting the fix in #2911.
TypeScript remains an alpha release (
2.8.1-alpha.0). - v2.8.02026-10-20 · 2026-10-20 18:40 UTC
查看更新说明
What's Changed
- Add API Route as an OpenAI-compatible provider in Python and the TypeScript alpha.
- Support adaptive thinking and effort for newer Claude models in both SDKs.
- Keep parallel tool calls separate when OpenAI-compatible streams omit a tool-call index, in both SDKs.
- Preserve Google streaming finish reasons and token usage from chunks without content, including usage-only chunks without a candidate.
- Preserve
AnnotatedandFieldconstraints in tool schemas without changing callable parameter names.
Python is released as
2.8.0; TypeScript remains an alpha at2.8.0-alpha.0on npm'salphatag.Full Changelog: https://github.com/Mirascope/mirascope/compare/v2.7.0...v2.8.0
- v2.7.02026-10-19 · 2026-10-19 19:19 UTC
查看更新说明
What's Changed
- Resume active development of the TypeScript alpha and align its supported providers with Python, including Anthropic beta support, Atlas Cloud, Cheaper Inference, MiniMax, Requesty, and xAI.
- Add TypeScript MCP tool pagination and validation of LLM-generated arguments for interface-based tools.
- Keep MLX documented as a Python-only provider.
- Release Python
2.7.0and TypeScript2.7.0-alpha.0. The TypeScript package remains an alpha release on npm'salphadist-tag.
Full Changelog: https://github.com/Mirascope/mirascope/compare/v2.6.0...v2.7.0
- v2.6.02026-10-19 · 2026-10-19 16:53 UTC
查看更新说明
What's Changed
- fix(ops): forward function metadata in VersionedCall for decorator stacking by @Lyt060814 in https://github.com/Mirascope/mirascope/pull/2858
- fix: emit OTel/Langfuse-conventional span attributes for @ops.trace tags and metadata by @mvanhorn in https://github.com/Mirascope/mirascope/pull/2868
- fix(llm): handle empty and whitespace-only tool call arguments by @ansh-rohilla in https://github.com/Mirascope/mirascope/pull/2887
- feat: Add MiniMax as built-in LLM provider by @octo-patch in https://github.com/Mirascope/mirascope/pull/2859
- fix(llm): include thoughts tokens in Google streaming output tokens by @ansh-rohilla in https://github.com/Mirascope/mirascope/pull/2888
- fix(anthropic): strip FORMAT_TOOL from re-encoded history to fix resume() HTTP 400 by @devteamaegis in https://github.com/Mirascope/mirascope/pull/2863
- fix(llm): preserve interleaved OpenAI completion tool streams by @March-7 in https://github.com/Mirascope/mirascope/pull/2890
- feat(providers): add RequestyProvider for Requesty's OpenAI-compatible router by @Thibaultjaigu in https://github.com/Mirascope/mirascope/pull/2882
- test(python): add e2e tests for llm.call for multiple image formats by @samyak1729 in https://github.com/Mirascope/mirascope/pull/2529
- fix(llm): encode ToolOutput results as JSON instead of Python repr by @ansh-rohilla in https://github.com/Mirascope/mirascope/pull/2886
- chore: bump minor version to 2.6.0 by @willbakst in https://github.com/Mirascope/mirascope/pull/2892
New Contributors
- @Lyt060814 made their first contribution in https://github.com/Mirascope/mirascope/pull/2858
- @mvanhorn made their first contribution in https://github.com/Mirascope/mirascope/pull/2868
- @ansh-rohilla made their first contribution in https://github.com/Mirascope/mirascope/pull/2887
- @octo-patch made their first contribution in https://github.com/Mirascope/mirascope/pull/2859
- @devteamaegis made their first contribution in https://github.com/Mirascope/mirascope/pull/2863
- @March-7 made their first contribution in https://github.com/Mirascope/mirascope/pull/2890
- @Thibaultjaigu made their first contribution in https://github.com/Mirascope/mirascope/pull/2882
- @samyak1729 made their first contribution in https://github.com/Mirascope/mirascope/pull/2529
Full Changelog: https://github.com/Mirascope/mirascope/compare/v2.5.0...v2.6.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Mirascope
Welcome to Mirascope, which allows you to use any frontier LLM with one unified interface.
Quick Start
Install Mirascope:
uv add "mirascope[all]"
Call LLMs with a Decorator
from mirascope import llm
@llm.call("anthropic/claude-sonnet-4-5")
def recommend_book(genre: str):
return f"Recommend a {genre} book."
response = recommend_book("fantasy")
print(response.text())
Get Structured Output
from pydantic import BaseModel
from mirascope import llm
class Book(BaseModel):
title: str
author: str
@llm.call("anthropic/claude-sonnet-4-5", format=Book)
def recommend_book(genre: str):
return f"Recommend a {genre} book."
book = recommend_book("fantasy").parse()
print(f"{book.title} by {book.author}")
Build an Agent with Tools
from pydantic import BaseModel
from mirascope import llm
class Book(BaseModel):
title: str
author: str
@llm.tool
def get_available_books(genre: str) -> list[Book]:
"""Get available books in the library by genre."""
return [Book(title="The Name of the Wind", author="Patrick Rothfuss")]
@llm.call("anthropic/claude-sonnet-4-5", tools=[get_available_books], format=Book)
def librarian(request: str):
return f"You are a librarian. Help the user: {request}"
response = librarian("I want a fantasy book")
while response.tool_calls:
response = response.resume(response.execute_tools())
book = response.parse()
print(f"Recommending: {book.title} by {book.author}")
For streaming, async, multi-turn conversations, and more, see the full documentation.
Monorepo Structure
This project is structured as a monorepo, that conceptually divides into four parts:
python/contains the Python implementation, and examples (inpython/examples)typescript/contains the Typescript implementation, and examples (intypescript/examples)website/contains the marketing website (docs, blog, landing page)docs/contains the unified cross-language documentation (indocs/content), as well as configuration needed to build the docs
For detailed information about the codebase structure, architecture, and design decisions, see STRUCTURE.md.
Developing the site
Use bun run website:dev to launch the dev server.
Note that Bun must be installed.
CI and local testing
We currently have four CI jobs:
- codespell: Checks for common misspellings including python, typescript, and docs repos
- python-lint: Linting and typechecking for Python code
- typescript-lint: Linting and typechecking for Typescript code
- cloudflare docs build: Builds and previews the documentation site
You can run bun run ci in the root directory to run all CI checks locally. If adding new checks to GitHub CI, please also add it to the ci script in root package.json as well.
Versioning
Mirascope uses Semantic Versioning.
License
This project is licensed under the MIT License.