client.ai.chat(request) calls the AI Gateway, an OpenAI-compatible chat completions endpoint. It needs the ai:chat scope and a Standard plan or above.
Examples use the client from Creating the client.
Request
request is a dict sent as the body, as is, so any other OpenAI parameter passes through. It is typed as squarecloud.types.ChatRequest.
The response has the OpenAI shape:
id, object, created, model, choices (index, message, finish_reason) and usage.
No streaming
ai.chat() does not stream: it returns the whole completion. "stream": True is 400 stream_not_supported.
Timeout
The gateway gives each request 90 seconds in total, then answers 503server_overloaded. The SDK waits at least 120 s before timing out, so you get the gateway’s answer.
Errors
AI errors use the OpenAI format, so their codes are lowercase. They still raise aSquareCloudAPIError, with code set to the OpenAI code (or its type when there is no code):
The SDK never retries AI errors: the request is a non-idempotent
POST. See the AI Gateway reference for plan limits.
Next steps
Errors
Error class, retries and rate limits.
AI Gateway reference
Models, plan limits and the OpenAI-compatible endpoint.

