> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainlit.io/llms.txt
> Use this file to discover all available pages before exploring further.

# FastAPI

Chainlit can be mounted as a FastAPI sub application.

```py my_cl_app theme={null}
import chainlit as cl

@cl.on_chat_start
async def main():
    await cl.Message(content="Hello World").send()
```

```py main theme={null}
from fastapi import FastAPI
from chainlit.utils import mount_chainlit

app = FastAPI()


@app.get("/app")
def read_main():
    return {"message": "Hello World from main app"}

mount_chainlit(app=app, target="my_cl_app.py", path="/chainlit")
```

In the example above, we have a FastAPI application with a single endpoint `/app`. We mount the Chainlit application `my_cl_app.py` to the `/chainlit` path.

Start the FastAPI server:

```bash theme={null}
uvicorn main:app --host 0.0.0.0 --port 80
```

<Note>
  When using FastAPI integration, header authentication is the preferred method
  for authenticating users. This approach allows Chainlit to delegate the
  authentication process to the parent FastAPI application, providing a more
  seamless and secure integration.
</Note>
