AI Gateway (Beta)
This documentation provides a comprehensive overview of the AI Gateway, Square Cloud’s OpenAI-compatible chat completions API.
string
required
The API key for your account. You can find this in your account settings.
cubic.
The AI Gateway is in beta with free early access: during the beta there is no extra charge beyond your plan’s daily AI token budget. Limits and plan availability may change when the beta ends.
How to connect
- Base URL:
https://api.squarecloud.app/v2/ai - API key: your account API key (the same one used by the Square Cloud API and CLI, from the account page). The
Authorizationheader is accepted with or without theBearerprefix. - Model:
cubic— Square Cloud’s hosted model, the same one powering the dashboard AI assistant.
Plans and limits
Requests are unlimited; every request bills its real tokens against your plan’s daily AI token budget (the same budget the dashboard assistant uses, reset at 00:00 UTC).Hobby plans (and accounts without a plan) do not have AI Gateway access — upgrading to Standard or above enables it.
Request contract
string
Accepted for SDK compatibility; the gateway always answers as
cubic.array
required
OpenAI-style messages with roles
system, user, assistant and tool. Content must be a string (no images/vision yet). Up to 100 messages per request.number
Silently clamped to your plan’s output ceiling.
number
From 0 to 2.
array
Function calling in the standard OpenAI format, up to 32 tool definitions. Tool calls come back as
finish_reason: "tool_calls", and you send results back as role: "tool" messages.string | object
Standard OpenAI
tool_choice values.stream: true returns 400 stream_not_supported) and images/vision.
Built-in web search
The model decides on its own to search the web when the conversation asks for current or external information. Searches run server-side, and only the final answer is returned, citing result URLs. If you declare your own tool namedweb_search, yours replaces the built-in one.
Errors
Errors use the OpenAI shape:{ "error": { "message", "type", "code" } }.
Frequently asked questions
Does it remember conversations?
Does it remember conversations?
No — the API is stateless, exactly like OpenAI’s: send the conversation history in
messages on every request.Which model is it?
Which model is it?
cubic, Square Cloud’s hosted model. There is no model list to choose from; the model field is accepted for SDK compatibility.Can I call it from an app hosted on Square Cloud?
Can I call it from an app hosted on Square Cloud?
Yes — that is the main use case. It is a normal HTTPS API, so it works from anywhere.
Does gateway usage affect my dashboard AI assistant?
Does gateway usage affect my dashboard AI assistant?
Yes: both consume the same daily AI token budget, so heavy gateway usage drains the budget available to the dashboard assistant and vice versa.

