# FastAPI Instrumentation

> Learn about best practices for creating rich OpenAPI Specifications when instrumenting FastAPI applications.

[FastAPI](https://fastapi.tiangolo.com/) is a popular Python web framework developed by [tiangolo](https://github.com/tiangolo).

The offering brands itself as

> FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.

FastAPI plays very nicely with Fern because it has the power to output OpenAPI Specifications! Below we'll outline some tips for generating a rich OpenAPI with FastAPI.

## OpenAPI generation

By default, FastAPI will generate an OpenAPI Specification for you based on your routes and your data models! You can access this spec by visiting `/docs` on your FastAPI server.

If you are not seeing any OpenAPI Specification (or the Swagger UI), you may need to review your FastAPI server configuration as the path may have been changed, or completely omitted.

```python {6-8}
from fastapi import FastAPI

...

FastAPI(
    openapi_url="/openapi.json",  # <-- this is the file and URL needed to access the OpenAPI Specification, `docs_url` and `redoc_url` are convenient wrappers that display the file in a UI!
    docs_url="/docs",             # <-- this is the URL to access the Swagger UI, which will point to your OpenAPI Specification
    redoc_url="/redoc"            # <-- this is the URL to access the ReDoc UI, which will point to your OpenAPI Specification
)
```

## Specifying servers

Fern will automatically generate clients that point to the servers you configure within your OpenAPI Specification, so it's important to specify the servers that your API will be hosted on.

```python {5}
from fastapi import FastAPI

...

app = FastAPI(servers=[{"url": "http://prod.test.com", "description": "Production server"}])