close

View as MarkdownOpen in Claude

Close the 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:

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")