Install & Compatibility
Where this runs
tested against v1.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.362s · 33.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.1s · import 1.266s · 33MB
32MB installed
● package 32MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
get_scalar_api_reference
✓ from scalar_fastapi import get_scalar_api_reference
OpenAPISource
✓ from scalar_fastapi import get_scalar_api_reference, OpenAPISource
Used for providing multiple OpenAPI sources to the documentation.
Layout
✓ from scalar_fastapi import Layout
Provides options for customizing the documentation layout.
Theme
✓ from scalar_fastapi import Theme
Provides options for customizing the documentation theme.
This example sets up a basic FastAPI application and integrates Scalar documentation at the `/scalar` endpoint. It uses `app.openapi_url` to automatically load the API's schema. Run with `uvicorn main:app --reload` and navigate to `/scalar`.
from fastapi import FastAPI
from scalar_fastapi import get_scalar_api_reference
import uvicorn
app = FastAPI(
title="My Awesome API",
description="A simple FastAPI application to demonstrate Scalar docs.",
version="1.0.0",
)
@app.get("/")
async def read_root():
return {"message": "Hello, World!"}
@app.get("/scalar", include_in_schema=False)
async def scalar_html():
return get_scalar_api_reference(
openapi_url=app.openapi_url,
title=app.title,
# Optional: Avoid CORS issues with a proxy
# scalar_proxy_url="https://proxy.scalar.com",
# Optional: Disable telemetry
# telemetry=False
)
# To run: uvicorn main:app --reload
# Then open http://127.0.0.1:8000/scalar in your browser
Debug
Known issues
gotchaTelemetry is enabled by default. To disable usage telemetry for privacy or compliance, explicitly set `telemetry=False` in the `get_scalar_api_reference` call.fixPass `telemetry=False` to `get_scalar_api_reference()`.
affects: All versions
gotchaThe AI Chat 'Agent' feature is enabled by default on localhost with limited free messages. For production environments, an Agent key is required for full functionality. Failing to provide a key will limit or disable the AI features.fixFor production, configure `agent=AgentScalarConfig(key="your-agent-scalar-key")` in `get_scalar_api_reference` or per `OpenAPISource`.
affects: All versions with Agent feature
deprecatedThe `hide_download_button` parameter in `get_scalar_api_reference` is deprecated. Use `document_download_type` instead to control the visibility and type of the OpenAPI document download button.fixReplace `hide_download_button=True` with `document_download_type=DocumentDownloadType.NONE` (or `JSON`, `YAML`, `BOTH` as needed).
affects: 1.5.0+
gotchaWhen serving the OpenAPI document from a different origin than Scalar (e.g., local development vs. hosted Scalar), CORS issues might occur. The documentation recommends using `scalar_proxy_url` to mitigate these problems.fixPass `scalar_proxy_url="https://proxy.scalar.com"` (or your own proxy URL) to `get_scalar_api_reference()`.
affects: All versions
gotchaThe `scalar-fastapi` Python package wraps a core JavaScript frontend library. While the underlying JS components (e.g., `@scalar/api-client`, `@scalar/api-reference`) receive very frequent updates and potentially major changes, the Python wrapper's release cycle is less frequent. Python users might experience a slight delay in new frontend features or minor breaking changes being reflected in the `scalar-fastapi` version.fixCheck the `scalar-fastapi` changelog (`integrations/fastapi/CHANGELOG.md` in the main Scalar GitHub repo) for Python-specific updates and breaking changes rather than solely relying on the overall Scalar project's release notes.
affects: All versions
Upgrade
Version history
1.9.0latest on PyPI · released Aug 28, 2026
Audit
Dependencies
fastapirequiredCore web framework required to generate OpenAPI schema.
uvicornoptionalASGI server to run FastAPI applications, necessary for quickstart examples.