> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# close

> Close the AIChatClient the gateway created.

[ref-chatgateway]: /docs/server-sdks/reference/python/agents/chat-gateway

[aichatclient]: /docs/server-sdks/reference/python/agents/ai-chat-client

Close the [`AIChatClient`][aichatclient] the gateway built for itself. A gateway constructed with
your own `client=` leaves that client alone, since it did not create it.

## **Parameters**

None.

## **Returns**

`None`.

## **Example**

Close it when your app shuts down:

```python {12}
from contextlib import asynccontextmanager

from fastapi import FastAPI
from signalwire.ai_chat import ChatGateway

gateway = ChatGateway(config_url="https://bayview-taxi.example.com/swml")


@asynccontextmanager
async def lifespan(app: FastAPI):
    yield
    await gateway.close()


app = FastAPI(lifespan=lifespan)
app.include_router(gateway.router(), prefix="/chat")
```